def inv(a): """ Compute the inverse of a matrix. Parameters ---------- a : array_like, shape (M, M) Matrix to be inverted Returns ------- ainv : ndarray, shape (M, M) Inverse of the matrix `a` Raises ------ LinAlgError If `a` is singular or not square. Examples -------- >>> a = np.array([[1., 2.], [3., 4.]]) >>> np.linalg.inv(a) array([[-2. , 1. ], [ 1.5, -0.5]]) >>> np.dot(a, np.linalg.inv(a)) array([[ 1., 0.], [ 0., 1.]]) """ a, wrap = _makearray(a) return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
def inv(a): """Compute the inverse of a matrix. Parameters ---------- a : array-like, shape (M, M) Matrix to be inverted Returns ------- ainv : array-like, shape (M, M) Inverse of the matrix a Raises LinAlgError if a is singular or not square Examples -------- >>> from numpy import array, inv, dot >>> a = array([[1., 2.], [3., 4.]]) >>> inv(a) array([[-2. , 1. ], [ 1.5, -0.5]]) >>> dot(a, inv(a)) array([[ 1., 0.], [ 0., 1.]]) """ a, wrap = _makearray(a) return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
def inv(a): a, wrap = _makearray(a) return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))