gpt4 book ai didi

python - 如何在python中表示矩阵

转载 作者:IT老高 更新时间:2023-10-28 22:24:10 25 4
gpt4 key购买 nike

如何在 python 中表示矩阵?

最佳答案

看看this answer :

from numpy import matrix
from numpy import linalg
A = matrix( [[1,2,3],[11,12,13],[21,22,23]]) # Creates a matrix.
x = matrix( [[1],[2],[3]] ) # Creates a matrix (like a column vector).
y = matrix( [[1,2,3]] ) # Creates a matrix (like a row vector).
print A.T # Transpose of A.
print A*x # Matrix multiplication of A and x.
print A.I # Inverse of A.
print linalg.solve(A, x) # Solve the linear equation system.

关于python - 如何在python中表示矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3127404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com