MCPcopy Index your code
hub / github.com/numpy/numpy / I

Method I

numpy/matrixlib/defmatrix.py:799–841  ·  view source on GitHub ↗

Returns the (multiplicative) inverse of invertible `self`. Parameters ---------- None Returns ------- ret : matrix object If `self` is non-singular, `ret` is such that ``ret * self`` == ``self * ret`` == ``np.matrix(n

(self)

Source from the content-addressed store, hash-verified

797
798 @property
799 def I(self): # noqa: E743
800 """
801 Returns the (multiplicative) inverse of invertible `self`.
802
803 Parameters
804 ----------
805 None
806
807 Returns
808 -------
809 ret : matrix object
810 If `self` is non-singular, `ret` is such that ``ret * self`` ==
811 ``self * ret`` == ``np.matrix(np.eye(self[0,:].size))`` all return
812 ``True``.
813
814 Raises
815 ------
816 numpy.linalg.LinAlgError: Singular matrix
817 If `self` is singular.
818
819 See Also
820 --------
821 linalg.inv
822
823 Examples
824 --------
825 >>> m = np.matrix('[1, 2; 3, 4]'); m
826 matrix([[1, 2],
827 [3, 4]])
828 >>> m.getI()
829 matrix([[-2. , 1. ],
830 [ 1.5, -0.5]])
831 >>> m.getI() * m
832 matrix([[ 1., 0.], # may vary
833 [ 0., 1.]])
834
835 """
836 M, N = self.shape
837 if M == N:
838 from numpy.linalg import inv as func
839 else:
840 from numpy.linalg import pinv as func
841 return asmatrix(func(self))
842
843 @property
844 def A(self):

Callers

nothing calls this directly

Calls 2

asmatrixFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected