3.10 矩阵与线性代数运算

    矩阵类似于3.9小节中数组对象,但是遵循线性代数的计算规则。下面的一个例子展示了矩阵的一些基本特性:

    1. >>> import numpy.linalg
    2.  
    3. >>> # Determinant
    4. >>> numpy.linalg.det(m)
    5. -229.99999999999983
    6. >>> # Eigenvalues
    7. >>> numpy.linalg.eigvals(m)
    8. array([-13.11474312, 2.75956154, 6.35518158])
    9.  
    10. >>> # Solve for x in mx = v
    11. >>> x = numpy.linalg.solve(m, v)
    12. >>> x
    13. matrix([[ 0.96521739],
    14. [ 0.46086957]])
    15. >>> m * x
    16. matrix([[ 2.],
    17. [ 3.],
    18. [ 4.]])
    19. >>> v
    20. matrix([[2],
    21. [3],
    22. >>>

    很显然线性代数是个非常大的主题,已经超出了本书能讨论的范围。但是,如果你需要操作数组和向量的话, 是一个不错的入口点。可以访问 官网 获取更多信息。

    http://python3-cookbook.readthedocs.io/zh_CN/latest/c03/p10_matrix_and_linear_algebra_calculation.html