svd
Performs a singular value decomposition of a matrix.
Signatures
- svd( matrix matA, matrix& matU, matrix& matW, matrix& matV )
- svd( float matA[][], float& matU[][], float& matW[][], float& matV[][] )
Details
Applies a singular value decomposition to the matrix. This means, that the given matrix A is expressed in the form
A = U * W * VT
with matrices U, W and V. Matrix W is diagonal and contains the singular values as diagonal elements.
The function supports two forms:
In the general form, for an LxM input array A, the resulting matrices have the following sizes:
- U is LxM
- W is MxM
- V is MxM
Example
matrix A = <[ <[ 1, 2, 3 ]>,
<[ 4, 5, 6 ]>,
<[ 7, 8, 9 ]> ]>
matrix U
matrix W
matrix V
svd( A, U, W, V )
echo( U * W * V.t() )
Output
<[<[1,2,3]>,<[4,5,6]>,<[7,8,9]>]>
Parameters
- matA
-
The input matrix A. This can be a matrix or a general LxM float array. No dimension must have a length of zero.
- matU
-
Returns the matrix U. Size is LxM for float arrays.
- matW
-
Returns the matrix W. Size is MxM for float arrays.
- matV
-
Returns the matrix V. Size is MxM for float arrays.