Files
Python_CookBook_repo/3.数字日期和时间/10.矩阵和线性代数的计算.py

17 lines
480 B
Python
Raw Permalink Normal View History

2025-09-10 16:12:45 +08:00
import numpy as np
if __name__ == '__main__':
# np在线性代数处理上有一个子包叫matrix专门使用线性代数规则来处理数据比如矩阵乘法、求行列式和解线性方程
m = np.matrix([[1,-2,3],[0,4,5],[7,8,-9]])
print(m)
# 做一个矩阵转置
print(m.T)
# 求可逆矩阵
print(m.I)
v = np.matrix([[2], [3], [4]])
print(m * v)
# 更多线代操作在np.linalg模块下可以找到随用随查就行