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

相关推荐
疋瓞8 小时前
python和C++对比(1)_数据类型和数据结构
数据结构·c++·python
phoenix@Capricornus9 小时前
单位球面在线性变换下的像以及线性变换诱导的加权 2-范数的等值面(To 战老师)
线性代数·机器学习·矩阵
如此这般英俊9 小时前
手搓Claude Code-第六章 subagent
数据结构·人工智能·python·语言模型·自然语言处理
foggyprojects10 小时前
从0开始,一句话启动AI DataAgent
后端·数据分析·ai编程
元Y亨H10 小时前
Python - FastAPI 全方位介绍
python·fastapi
error:(12 小时前
【系统与实战双精通】VS Code 调试 ROS2 Python 节点与 Launch 系统指南
android·java·python
weigangwin12 小时前
LlamaIndex 第一次试用:别先写 RAG Demo,先验上下文合同
python·ai·agent·rag·检索·llamaindex·观测性
省四收割者12 小时前
一文详解信号完整性(1)
python·嵌入式硬件·数学建模·信息与通信·信号处理·智能硬件
ai生成式引擎优化技术13 小时前
从知识连接到智能组织:WSaiOS认知网络的理论框架与系统设计摘要
网络·python·plotly·django·pygame
用户83562907805113 小时前
使用 Python 保护和取消保护 Excel 工作表和工作簿
后端·python