dpnp.linalg.pinv
- dpnp.linalg.pinv(a, rcond=None, hermitian=False, *, rtol=None)[source]
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.
For full documentation refer to
numpy.linalg.inv
.- Parameters:
a ((..., M, N) {dpnp.ndarray, usm_ndarray}) -- Matrix or stack of matrices to be pseudo-inverted.
rcond ((...) {None, float, dpnp.ndarray, usm_ndarray}, optional) -- Cutoff for small singular values. Singular values less than or equal to
rcond * largest_singular_value
are set to zero. Broadcasts against the stack of matrices. Only rcond or rtol can be set at a time. If none of them are provided, defaults tomax(M, N) * dpnp.finfo(a.dtype).eps
. Default:None
.hermitian (bool, optional) -- If
True
, a is assumed to be Hermitian (symmetric if real-valued), enabling a more efficient method for finding singular values. Default:False
.rtol ((...) {None, float, dpnp.ndarray, usm_ndarray}, optional) -- Same as rcond, but it's an Array API compatible parameter name. Only rcond or rtol can be set at a time. If none of them are provided, defaults to
max(M, N) * dpnp.finfo(a.dtype).eps
. Default:None
.
- Returns:
out -- The pseudo-inverse of a.
- Return type:
(..., N, M) dpnp.ndarray
Examples
The following example checks that
a * a+ * a == a
anda+ * a * a+ == a+
:>>> import dpnp as np >>> a = np.random.randn(9, 6) >>> B = np.linalg.pinv(a) >>> np.allclose(a, np.dot(a, np.dot(B, a))) array(True) >>> np.allclose(B, np.dot(B, np.dot(a, B))) array(True)