《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 数组。

相关推荐
LeocenaY几秒前
搜集的一些测开面试题
开发语言·python
嗝o゚1 分钟前
昇腾CANN ge 仓的图优化 Pass:哪些 Pass 真正影响推理性能
pytorch·python·深度学习·cann·ge-pass
深度先生29 分钟前
Conda 全面讲解——数据科学家的标配工具
python
深度先生1 小时前
虚拟环境:别让包打架
python
漠效1 小时前
随机代理‌IP访问脚本
开发语言·python
SilentSamsara1 小时前
元类与 __init_subclass__:类是如何被“创建“出来的
开发语言·python·青少年编程
隔壁大炮2 小时前
MNE-Python 第6天学习笔记:分段(Epoching)与基线校正
python·eeg·mne·脑电数据处理
SilentSamsara2 小时前
concurrent.futures 实战:进程池与线程池的统一抽象
运维·开发语言·python·青少年编程
水木流年追梦2 小时前
大模型入门-大模型的推理策略
开发语言·python·算法·正则表达式·prompt
Cthy_hy2 小时前
Python 算法竞赛:数学核心知识点全总结
python·算法