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

相关推荐
计算机徐师兄11 分钟前
Python基于Django的网络入侵检测系统(附源码,文档说明)
python·django·网络入侵检测·网络入侵检测系统·python网络入侵检测系统·网络入侵·python网络入侵检测
大连好光景24 分钟前
socket.socket模块--网络通信
网络·python·网络协议
codists44 分钟前
《Grokking Concurrency》读后感
python
坤岭1 小时前
Python内存溢出问题
python
三木彤1 小时前
Python 反爬 UA 检测真实案例(3个典型场景,可复现、合法合规)
python
SCBAiotAigc1 小时前
MinerU离线推理
人工智能·python·mineru
94620164zwb51 小时前
关于应用模块 Cordova 与 OpenHarmony 混合开发实战
python·学习
趁月色小酌***1 小时前
JAVA 知识点总结5
java·开发语言·python
natide1 小时前
表示/嵌入差异-1-欧几里得距离(Euclidean Distance)-L2 距离(L2 distance)-欧式距离的标准化
人工智能·pytorch·python·深度学习·算法·自然语言处理
对方正在长头发丿1 小时前
Numpy学习篇
python·学习·jupyter·pycharm·numpy