Computes the singular value decomposition of a matrix. More...
Functions | |
AFAPI void | svd (array &u, array &s, array &vt, const array &in) |
C++ Interface for SVD decomposition. | |
AFAPI void | svdInPlace (array &u, array &s, array &vt, array &in) |
C++ Interface for SVD decomposition (in-place) | |
AFAPI af_err | af_svd (af_array *u, af_array *s, af_array *vt, const af_array in) |
C Interface for SVD decomposition. | |
AFAPI af_err | af_svd_inplace (af_array *u, af_array *s, af_array *vt, af_array in) |
C Interface for SVD decomposition (in-place) | |
Computes the singular value decomposition of a matrix.
This function factorizes a matrix \(A\) into two unitary matrices, \(U\) and \(V^T\), and a diagonal matrix \(S\), such that \(A = USV^T\). If \(A\) has \(M\) rows and \(N\) columns ( \(M \times N\)), then \(U\) will be \(M \times M\), \(V\) will be \(N \times N\), and \(S\) will be \(M \times N\). However, for \(S\), this function only returns the non-zero diagonal elements as a sorted (in descending order) 1D array.
To reconstruct the original matrix \(A\) from the individual factors, the following code snippet can be used:
When memory is a concern, and \(A\) is dispensable, af::svdInPlace() can be used. However, this in-place version is currently limited to input arrays where \(M \geq N\).
C Interface for SVD decomposition.
[out] | u | is the output array containing U |
[out] | s | is the output array containing the diagonal values of sigma, (singular values of the input matrix)) |
[out] | vt | is the output array containing V^H |
[in] | in | is the input matrix |
C Interface for SVD decomposition (in-place)
[out] | u | is the output array containing U |
[out] | s | is the output array containing the diagonal values of sigma, (singular values of the input matrix)) |
[out] | vt | is the output array containing V^H |
[in,out] | in | is the input matrix that will contain random data after this operation |
in
is limited to arrays where dim0
\(\geq\) dim1
in
is dispensable C++ Interface for SVD decomposition.
[out] | u | is the output array containing U |
[out] | s | is the output array containing the diagonal values of sigma, (singular values of the input matrix)) |
[out] | vt | is the output array containing V^H |
[in] | in | is the input matrix |
C++ Interface for SVD decomposition (in-place)
[out] | u | is the output array containing U |
[out] | s | is the output array containing the diagonal values of sigma, (singular values of the input matrix)) |
[out] | vt | is the output array containing V^H |
[in,out] | in | is the input matrix and will contain random data after this operation |
in
is limited to arrays where dim0
\(\geq\) dim1
in
is dispensable