Pseudo-invert (Moore-Penrose) a matrix. More...
Pseudo-invert (Moore-Penrose) a matrix.
This function calculates the Moore-Penrose pseudoinverse of a matrix \(A\), using af::svd at its core. If \(A\) is of size \(M \times N\), then its pseudoinverse \(A^+\) will be of size \(N \times M\).
This calculation can be batched if the input array is three or four-dimensional \((M \times N \times P \times Q\), with \(Q=1\) for only three dimensions \()\). Each \(M \times N\) slice along the third dimension will have its own pseudoinverse, for a total of \(P \times Q\) pseudoinverses in the output array \((N \times M \times P \times Q)\).
Below is an example snippet of its usage. In this example, we have a matrix \(A\) and compute its pseudoinverse \(A^+\). This condition must hold: \(AA^+A=A\), given that the two matrices are pseudoinverses of each other (in fact, this is one of the Moore-Penrose conditions):
float hA[] = {0, 1, 2, 3, 4, 5};
array A(3, 2, hA);
array Apinv = pinverse(A);
array MustBeA = matmul(A, Apinv, A);
◆ af_pinverse()C Interface to pseudo-invert (Moore-Penrose) a matrix.
Currently uses the SVD-based approach.
Parameter tol
is not the actual lower threshold, but it is passed in as a parameter to the calculation of the actual threshold relative to the shape and contents of in
.
Suggested parameters for tol
: 1e-6 for single precision and 1e-12 for double precision.
C++ Interface to pseudo-invert (Moore-Penrose) a matrix.
Currently uses the SVD-based approach.
Parameter tol
is not the actual lower threshold, but it is passed in as a parameter to the calculation of the actual threshold relative to the shape and contents of in
.
This function is not supported in GFOR.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4