SingularValueDecomposition Class |
Namespace: Novacta.Analytics.Advanced
Name | Description | |
---|---|---|
Decompose(ComplexMatrix, ComplexMatrix, ComplexMatrix) |
Computes the Singular Value Decomposition of the
specified matrix.
| |
Decompose(DoubleMatrix, DoubleMatrix, DoubleMatrix) |
Computes the Singular Value Decomposition of the
specified matrix.
| |
Decompose(ReadOnlyComplexMatrix, ComplexMatrix, ComplexMatrix) |
Computes the Singular Value Decomposition of the
specified matrix.
| |
Decompose(ReadOnlyDoubleMatrix, DoubleMatrix, DoubleMatrix) |
Computes the Singular Value Decomposition of the
specified matrix.
| |
GetSingularValues(ComplexMatrix) |
Computes the singular values of the specified matrix.
| |
GetSingularValues(DoubleMatrix) |
Computes the singular values of the specified matrix.
| |
GetSingularValues(ReadOnlyComplexMatrix) |
Computes the singular values of the specified matrix.
| |
GetSingularValues(ReadOnlyDoubleMatrix) |
Computes the singular values of the specified matrix.
|
Let be a matrix having rows and columns.
The Singular Value Decomposition (SVD) of is a factorization
having the following form:
where returns the conjugate transpose of
, and are unitary complex
matrices having sizes and ,
respectively, and
is a diagonal real matrix.
Matrix has
columns known as left singular vectors.
Matrix has diagonal entries known as the
singular values of . Finally,
matrix has rows that represent
the conjugate transposed right singular vectors
of .
Method Decompose(DoubleMatrix, DoubleMatrix, DoubleMatrix) and its overloads compute matrices , , and for double or complex matrices.
Method GetSingularValues(DoubleMatrix) and its overloads return the singular values involved in a decomposition, without computing the corresponding singular vectors.
In the following example, the SVD of a matrix is computed.
using System; using Novacta.Analytics.Advanced; namespace Novacta.Analytics.CodeExamples.Advanced { public class SingularValueDecompositionExample0 { public void Main() { // Create a matrix. var data = new double[6] { 1, 8, 2, 2, -3, 9 }; var matrix = DoubleMatrix.Dense(3, 2, data, StorageOrder.RowMajor); Console.WriteLine("Matrix to be decomposed:"); Console.WriteLine(matrix); // Compute its SVD. var singularValues = SingularValueDecomposition.Decompose( matrix, out DoubleMatrix leftSingularVectors, out DoubleMatrix conjugateTransposedRightSingularVectors); Console.WriteLine(); Console.WriteLine("Singular values:"); Console.WriteLine(singularValues); Console.WriteLine(); Console.WriteLine("Left singular vectors:"); Console.WriteLine(leftSingularVectors); Console.WriteLine(); Console.WriteLine("Conjugate transposed right singular vectors:"); Console.WriteLine(conjugateTransposedRightSingularVectors); Console.WriteLine(); Console.WriteLine("Matrix reconstruction:"); var v = singularValues; var l = leftSingularVectors; var rh = conjugateTransposedRightSingularVectors; Console.WriteLine(l * v * rh); } } } // Executing method Main() produces the following output: // // Matrix to be decomposed: // 1 8 // 2 2 // -3 9 // // // // Singular values: // 12.273817 0 // 0 3.51474275 // 0 0 // // // // Left singular vectors: // 0.639011869 0.531180587 0.556337142 // 0.144195105 0.627724866 -0.76496357 // 0.755560456 -0.569041894 -0.32453 // // // // Conjugate transposed right singular vectors: // -0.109116772 0.994028938 // 0.994028938 0.109116772 // // // // Matrix reconstruction: // 1 8 // 2 2 // -3 9 //