如何在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/

10-11 22:24
查看更多