Inverse of a matrix using numpy

前端 未结 4 668
-上瘾入骨i
-上瘾入骨i 2020-12-23 16:09

I\'d like to use numpy to calculate the inverse. But I\'m getting an error:

\'numpy.ndarry\' object has no attribute I

To calculate inver

4条回答
  •  礼貌的吻别
    2020-12-23 16:40

    Another way to do this is to use the numpy matrix class (rather than a numpy array) and the I attribute. For example:

    >>> m = np.matrix([[2,3],[4,5]])
    >>> m.I
    matrix([[-2.5,  1.5],
           [ 2. , -1. ]])
    

提交回复
热议问题