《Python数据分析技术栈》第05章 06 矩阵(Matrices)

06 矩阵(Matrices)

《Python数据分析技术栈》第05章 06 矩阵(Matrices)

A matrix is a two-dimensional data structure, while an array can consist of any number of dimensions.

矩阵是一种二维数据结构,而数组可以包含任意维数。

With the np.matrix class, we can create a matrix object, using the following syntax:

通过 np.matrix 类,我们可以使用以下语法创建一个矩阵对象:

python 复制代码
x=np.matrix([[2,3],[33,3],[4,1]])
#OR
x=np.matrix('2,3;33,3;4,1') #Using semicolons to separate the rows x

Most of the functions that can be applied to arrays can be used on matrices as well. Matrices use some arithmetic operators that make matrix operations more intuitive. For instance, we can use the * operator to get the dot product of two matrices that replicates the functionality of the np.dot function.

大多数可用于数组的函数也可用于矩阵。矩阵使用一些算术运算符,使矩阵运算更加直观。例如,我们可以使用 * 运算符获取两个矩阵的点积,这与 np.dot 函数的功能相同。

Since matrices are just one specific case of arrays and might be deprecated in future releases of NumPy, it is generally preferable to use NumPy arrays.

由于矩阵只是数组的一种特殊情况,而且在未来的 NumPy 版本中可能会被弃用,因此通常最好使用 NumPy 数组。

相关推荐
AI松子66613 分钟前
PyTorch-混合精度训练(amp)
人工智能·pytorch·python
MDLZH13 分钟前
Pytorch性能调优简单总结
人工智能·pytorch·python
程序员爱钓鱼1 小时前
Python 编程实战 · 实用工具与库 — Flask 路由与模板
前端·后端·python
程序员爱钓鱼1 小时前
Python 编程实战 · 实用工具与库 — Django 项目结构简介
后端·python·面试
新之助小锅2 小时前
java版连接汇川PLC,发送数据,读取数据,保持重新链接,适用安卓
android·java·python
海琴烟Sunshine2 小时前
leetcode 383. 赎金信 python
python·算法·leetcode
惊讶的猫8 小时前
LSTM论文解读
开发语言·python
测试老哥9 小时前
软件测试之单元测试知识总结
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
buvsvdp50059ac9 小时前
如何在VSCode中设置Python解释器?
ide·vscode·python
njxiejing9 小时前
Python进度条工具tqdm的安装与使用
开发语言·python