pinv¶
- pinv(x: array, /, *, rtol: float | array | None = None) array¶
Returns the (Moore-Penrose) pseudo-inverse of a matrix (or a stack of matrices)
x.The pseudo-inverse of a matrix \(A\), denoted \(A^{+}\), is defined as the matrix that “solves” the least-squares problem \(Ax = b\) (i.e., if \(\overline{x}\) is a solution, then \(A^{+}\) is the matrix such that \(\overline{x} = A^{+}b\)).
While the pseudo-inverse can be defined algebraically, one can understand the pseudo-inverse via singular value decomposition (SVD). Namely, if
\[A = U \Sigma V^H\]is a singular decomposition of \(A\), then
\[A^{+} = U \Sigma^{+} V^H\]where \(U\) and \(V^H\) are orthogonal matrices, \(\Sigma\) is a diagonal matrix consisting of \(A\)’s singular values, and \(\Sigma^{+}\) is then a diagonal matrix consisting of the reciprocals of \(A\)’s singular values, leaving zeros in place. During numerical computation, only elements larger than a small tolerance are considered nonzero, and all others replaced by zeros.
When
xis a stack of matrices, the function must compute the pseudo-inverse for each matrix in the stack.- Parameters:
x (array) – input array having shape
(..., M, N)and whose innermost two dimensions formMxNmatrices. Should have a floating-point data type.rtol (Optional[Union[float, array]]) – relative tolerance for small singular values. Singular values approximately less than or equal to
rtol * largest_singular_valueare set to zero. If afloat, the value is equivalent to a zero-dimensional array having a real-valued floating-point data type determined by Type Promotion Rules (as applied tox) and must be broadcast against each matrix. If anarray, must have a real-valued floating-point data type and must be compatible withshape(x)[:-2](see Broadcasting). IfNone, the default value ismax(M, N) * eps, whereepsmust be the machine epsilon associated with the real-valued floating-point data type determined by Type Promotion Rules (as applied tox). Default:None.
- Returns:
out (array) – an array containing the pseudo-inverse(s). The returned array must have a floating-point data type determined by Type Promotion Rules and must have shape
(..., N, M)(i.e., must have the same shape asx, except the innermost two dimensions must be transposed).
Notes
Changed in version 2022.12: Added complex data type support.