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

相关推荐
wuyk5552 小时前
Python 第三章:列表 List
服务器·开发语言·python
笨鸟先飞,勤能补拙2 小时前
从预测到决策:人工智能与机器学习的系统方法、工程闭环与现实边界
大数据·人工智能·windows·python·机器学习·密码学
MgArcher2 小时前
抖音a_bogus参数逆向实战:JSVMP环境模拟与Hook技术(2025最新)
javascript·爬虫·python
circuitsosk2 小时前
AI输出的“质检员”:构建智能体质量评估、异常检测与人工兜底的三层防线
人工智能·python·microsoft·正则表达式·langchain
要努力点3 小时前
Python入门第六课
开发语言·python
CTA终结者3 小时前
先用小策略练清条件和动作
人工智能·python
Bruce_Liuxiaowei3 小时前
从零到可运行:基于 Vue3 + FastAPI + DeepSeek-V3 的 AI 英语单词学习系统全栈实战
人工智能·python·学习·fastapi·全栈·智能体
ValhallaCoder3 小时前
Leetcode-hot100(2026.08.17)
python·算法·leetcode
W_326003 小时前
Python-OpenCV图像像素与通道:通道拆分合并、深浅拷贝
图像处理·人工智能·python·opencv·机器学习
CIO_Alliance4 小时前
AI基础系列(1)| 向量、矩阵、张量在AI中分别扮演什么角色?
大数据·人工智能·线性代数·ai·矩阵·企业cio联盟·企业级ai化转型