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

相关推荐
小鹿( ﹡ˆoˆ﹡ )19 分钟前
探索IP协议的神秘面纱:Python中的网络通信
python·tcp/ip·php
卷心菜小温34 分钟前
【BUG】P-tuningv2微调ChatGLM2-6B时所踩的坑
python·深度学习·语言模型·nlp·bug
陈苏同学1 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
唐家小妹1 小时前
介绍一款开源的 Modern GUI PySide6 / PyQt6的使用
python·pyqt
羊小猪~~2 小时前
深度学习项目----用LSTM模型预测股价(包含LSTM网络简介,代码数据均可下载)
pytorch·python·rnn·深度学习·机器学习·数据分析·lstm
Marst Code2 小时前
(Django)初步使用
后端·python·django
985小水博一枚呀2 小时前
【对于Python爬虫的理解】数据挖掘、信息聚合、价格监控、新闻爬取等,附代码。
爬虫·python·深度学习·数据挖掘
立秋67892 小时前
Python的defaultdict详解
服务器·windows·python
萧鼎3 小时前
Python第三方库选择与使用陷阱避免
开发语言·python
白拾3 小时前
使用Conda管理python环境的指南
开发语言·python·conda