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

相关推荐
gc_22997 分钟前
学习python调用dmpython库获取达梦数据库模式信息的基本方式
python·dmpython
reasonsummer8 分钟前
【教学类-130-01】20260118对称汉字剪纸28个
python
victory04318 分钟前
minimind SFT失败原因排查和解决办法
人工智能·python·深度学习
曲幽21 分钟前
Django入门指南:Python Web开发的“瑞士军刀”
python·django·flask·fastapi·web·pythonweb
m0_7482495424 分钟前
Java 语言提供了八种基本类型【文123】
java·开发语言·python
移幻漂流29 分钟前
Kotlin 如何解决 Java 的核心痛点:现代语言特性的深度剖析
java·python·kotlin
我的xiaodoujiao31 分钟前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 41--自定义定制化展示 Allure 测试报告内容
python·学习·测试工具·pytest
2501_9421917733 分钟前
YOLO11-Seg-SwinTransformer榛子缺陷识别实战
python
闻道且行之1 小时前
基于 LLM 的 MCP 架构实战:服务端搭建、工具开发与 Dify 集成全流程
python·架构·nlp·dify·mcp
老蒋每日coding1 小时前
Python:数字时代的“万能钥匙”
开发语言·python