MCPcopy
hub / github.com/numpy/numpy / pinv

Function pinv

numpy/linalg/_linalg.py:2154–2265  ·  view source on GitHub ↗

Compute the (Moore-Penrose) pseudo-inverse of a matrix. Calculate the generalized inverse of a matrix using its singular-value decomposition (SVD) and including all *large* singular values. Parameters ---------- a : (..., M, N) array_like Matrix or stack of mat

(a, rcond=None, hermitian=False, *, rtol=_NoValue)

Source from the content-addressed store, hash-verified

2152
2153@array_function_dispatch(_pinv_dispatcher)
2154def pinv(a, rcond=None, hermitian=False, *, rtol=_NoValue):
2155 """
2156 Compute the (Moore-Penrose) pseudo-inverse of a matrix.
2157
2158 Calculate the generalized inverse of a matrix using its
2159 singular-value decomposition (SVD) and including all
2160 *large* singular values.
2161
2162 Parameters
2163 ----------
2164 a : (..., M, N) array_like
2165 Matrix or stack of matrices to be pseudo-inverted.
2166 rcond : (...) array_like of float, optional
2167 Cutoff for small singular values.
2168 Singular values less than or equal to
2169 ``rcond * largest_singular_value`` are set to zero.
2170 Broadcasts against the stack of matrices. Default: ``1e-15``.
2171 hermitian : bool, optional
2172 If True, `a` is assumed to be Hermitian (symmetric if real-valued),
2173 enabling a more efficient method for finding singular values.
2174 Defaults to False.
2175 rtol : (...) array_like of float, optional
2176 Same as `rcond`, but it's an Array API compatible parameter name.
2177 Only `rcond` or `rtol` can be set at a time. If none of them are
2178 provided then NumPy's ``1e-15`` default is used. If ``rtol=None``
2179 is passed then the API standard default is used.
2180
2181 .. versionadded:: 2.0.0
2182
2183 Returns
2184 -------
2185 B : (..., N, M) ndarray
2186 The pseudo-inverse of `a`. If `a` is a `matrix` instance, then so
2187 is `B`.
2188
2189 Raises
2190 ------
2191 LinAlgError
2192 If the SVD computation does not converge.
2193
2194 See Also
2195 --------
2196 scipy.linalg.pinv : Similar function in SciPy.
2197 scipy.linalg.pinvh : Compute the (Moore-Penrose) pseudo-inverse of a
2198 Hermitian matrix.
2199
2200 Notes
2201 -----
2202 The pseudo-inverse of a matrix A, denoted :math:`A^+`, is
2203 defined as: "the matrix that 'solves' [the least-squares problem]
2204 :math:`Ax = b`," i.e., if :math:`\\bar{x}` is said solution, then
2205 :math:`A^+` is that matrix such that :math:`\\bar{x} = A^+b`.
2206
2207 It can be shown that if :math:`Q_1 \\Sigma Q_2^T = A` is the singular
2208 value decomposition of A, then
2209 :math:`A^+ = Q_2 \\Sigma^+ Q_1^T`, where :math:`Q_{1,2}` are
2210 orthogonal matrices, :math:`\\Sigma` is a diagonal matrix consisting
2211 of A's so-called singular values, (followed, typically, by

Callers

nothing calls this directly

Calls 13

finfoClass · 0.90
asarrayFunction · 0.90
amaxFunction · 0.90
multiplyFunction · 0.90
_makearrayFunction · 0.85
_is_empty_2dFunction · 0.85
emptyFunction · 0.85
wrapFunction · 0.85
svdFunction · 0.85
matmulFunction · 0.85
conjugateMethod · 0.80
transposeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…