MCPcopy Create free account
hub / github.com/numpy/numpy / I

Method I

numpy/matrixlib/defmatrix.py:794–836  ·  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

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

Callers

nothing calls this directly

Calls 2

asmatrixFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected