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

相关推荐
钱多多_qdd2 分钟前
第一次使用mac,安装java相关的东西
java·python·macos
小小小米粒2 分钟前
CSV 是什么?
python
阿kun要赚马内6 分钟前
Python五类数据容器的对比和通用方法
开发语言·python
易海聚大数据10 分钟前
开源情报系统与网络舆情监测系统的核心差异在哪里
数据分析·智能分析·舆情监测系统·开源情报分析系统
Data-Miner11 分钟前
Excel-Agent:你的专属 AI 数据分析助手
人工智能·数据分析·excel
好家伙VCC11 分钟前
# 发散创新:用 Rust 实现高性能事件驱动架构的实践与优化 在现代软件系统中,**事件驱动编程模型**已经成为构
java·开发语言·python·架构·rust
梦醒过后说珍重13 分钟前
Python 工程化实战:如何将复杂的EndoMamba感知损失封装为“即插即用”的独立模块包
python·深度学习
爱钓鱼的程序员小郭16 分钟前
阿里云自动配置安全组IP白名单
python·tcp/ip·安全·阿里云
梦醒过后说珍重18 分钟前
PyTorch 工程实践:如何优雅地将 ViT 大模型封装为即插即用的感知损失(Perceptual Loss)
python·深度学习
guoyunsky21 分钟前
Ins爬虫可以抓取到国家,性别和年龄吗?
爬虫·数据分析·rpa