Class SingularValueDecomposition
Singular Value Decomposition for a rectangular matrix.
Inheritance
Implements
Namespace: ISynergy.Framework.Mathematics.Decompositions
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public sealed class SingularValueDecomposition : ICloneable, ISolverMatrixDecomposition<double>
Remarks
For an m-by-n matrix A
with m >= n
, the singular value decomposition
is an m-by-n orthogonal matrix U
, an n-by-n diagonal matrix S
, and
an n-by-n orthogonal matrix V
so that A = U * S * V'
.
The singular values, sigma[k] = S[k,k]
, are ordered so that
sigma[0] >= sigma[1] >= ... >= sigma[n-1]
.
The singular value decomposition always exists, so the constructor will never fail. The matrix condition number and the effective numerical rank can be computed from this decomposition.
WARNING! Please be aware that if A has less rows than columns, it is better to compute the decomposition on the transpose of A and then swap the left and right eigenvectors. If the routine is computed on A directly, the diagonal of singular values may contain one or more zeros. The identity A = U * S * V' may still hold, however. To overcome this problem, pass true to the autoTranspose argument of the class constructor.
This routine computes the economy decomposition of A.
Constructors
View SourceSingularValueDecomposition(Double[,])
Constructs a new singular value decomposition.
Declaration
public SingularValueDecomposition(double[, ] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | The matrix to be decomposed. |
SingularValueDecomposition(Double[,], Boolean, Boolean)
Constructs a new singular value decomposition.
Declaration
public SingularValueDecomposition(double[, ] value, bool computeLeftSingularVectors, bool computeRightSingularVectors)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | The matrix to be decomposed. |
System.Boolean | computeLeftSingularVectors | Pass true if the left singular vector matrix U should be computed. Pass false otherwise. Default is true. |
System.Boolean | computeRightSingularVectors | Pass true if the right singular vector matrix V should be computed. Pass false otherwise. Default is true. |
SingularValueDecomposition(Double[,], Boolean, Boolean, Boolean)
Constructs a new singular value decomposition.
Declaration
public SingularValueDecomposition(double[, ] value, bool computeLeftSingularVectors, bool computeRightSingularVectors, bool autoTranspose)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | The matrix to be decomposed. |
System.Boolean | computeLeftSingularVectors | Pass true if the left singular vector matrix U should be computed. Pass false otherwise. Default is true. |
System.Boolean | computeRightSingularVectors | Pass true if the right singular vector matrix V should be computed. Pass false otherwise. Default is true. |
System.Boolean | autoTranspose | Pass true to automatically transpose the value matrix in case JAMA's assumptions about the dimensionality of the matrix are violated. Pass false otherwise. Default is false. |
SingularValueDecomposition(Double[,], Boolean, Boolean, Boolean, Boolean)
Constructs a new singular value decomposition.
Declaration
public SingularValueDecomposition(double[, ] value, bool computeLeftSingularVectors, bool computeRightSingularVectors, bool autoTranspose, bool inPlace)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | The matrix to be decomposed. |
System.Boolean | computeLeftSingularVectors | Pass true if the left singular vector matrix U should be computed. Pass false otherwise. Default is true. |
System.Boolean | computeRightSingularVectors | Pass true if the right singular vector matrix V should be computed. Pass false otherwise. Default is true. |
System.Boolean | autoTranspose | Pass true to automatically transpose the value matrix in case JAMA's assumptions about the dimensionality of the matrix are violated. Pass false otherwise. Default is false. |
System.Boolean | inPlace | Pass true to perform the decomposition in place. The matrix
|
Properties
View SourceAbsoluteDeterminant
Returns the absolute value of the matrix determinant.
Declaration
public double AbsoluteDeterminant { get; }
Property Value
Type | Description |
---|---|
System.Double |
Condition
Returns the condition number max(S) / min(S)
.
Declaration
public double Condition { get; }
Property Value
Type | Description |
---|---|
System.Double |
Diagonal
Gets the one-dimensional array of singular values.
Declaration
public double[] Diagonal { get; }
Property Value
Type | Description |
---|---|
System.Double[] |
DiagonalMatrix
Returns the block diagonal matrix of singular values.
Declaration
public double[, ] DiagonalMatrix { get; }
Property Value
Type | Description |
---|---|
System.Double[,] |
IsSingular
Gets whether the decomposed matrix is singular.
Declaration
public bool IsSingular { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LeftSingularVectors
Returns the U matrix of Singular Vectors.
Declaration
public double[, ] LeftSingularVectors { get; }
Property Value
Type | Description |
---|---|
System.Double[,] |
LogDeterminant
Returns the log of the absolute value for the matrix determinant.
Declaration
public double LogDeterminant { get; }
Property Value
Type | Description |
---|---|
System.Double |
LogPseudoDeterminant
Returns the log of the pseudo-determinant for the matrix.
Declaration
public double LogPseudoDeterminant { get; }
Property Value
Type | Description |
---|---|
System.Double |
Ordering
Returns the ordering in which the singular values have been sorted.
Declaration
public int[] Ordering { get; }
Property Value
Type | Description |
---|---|
System.Int32[] |
PseudoDeterminant
Returns the pseudo-determinant for the matrix.
Declaration
public double PseudoDeterminant { get; }
Property Value
Type | Description |
---|---|
System.Double |
Rank
Returns the effective numerical matrix rank.
Declaration
public int Rank { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Number of non-negligible singular values. |
RightSingularVectors
Returns the V matrix of Singular Vectors.
Declaration
public double[, ] RightSingularVectors { get; }
Property Value
Type | Description |
---|---|
System.Double[,] |
Threshold
Returns the singularity threshold.
Declaration
public double Threshold { get; }
Property Value
Type | Description |
---|---|
System.Double |
TwoNorm
Returns the Two norm.
Declaration
public double TwoNorm { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
View SourceClone()
Creates a new object that is a copy of the current instance.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | A new object that is a copy of this instance. |
GetInformationMatrix()
Computes (Xt * X)^1
(the inverse of the covariance matrix). This
matrix can be used to determine standard errors for the coefficients when
solving a linear set of equations through any of the
Declaration
public double[, ] GetInformationMatrix()
Returns
Type | Description |
---|---|
System.Double[,] |
Inverse()
Computes the (pseudo-)inverse of the matrix given to the Singular value decomposition.
Declaration
public double[, ] Inverse()
Returns
Type | Description |
---|---|
System.Double[,] |
Reverse()
Reverses the decomposition, reconstructing the original matrix X
.
Declaration
public double[, ] Reverse()
Returns
Type | Description |
---|---|
System.Double[,] |
Solve(Double[])
Solves a linear equation system of the form Ax = b.
Declaration
public double[] Solve(double[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | value | The b from the equation Ax = b. |
Returns
Type | Description |
---|---|
System.Double[] | The x from equation Ax = b. |
Solve(Double[,])
Solves a linear equation system of the form AX = B.
Declaration
public double[, ] Solve(double[, ] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | Parameter B from the equation AX = B. |
Returns
Type | Description |
---|---|
System.Double[,] | The solution X from equation AX = B. |
SolveForDiagonal(Double[])
Solves a linear equation system of the form AX = B.
Declaration
public double[, ] SolveForDiagonal(double[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | value | Parameter B from the equation AX = B. |
Returns
Type | Description |
---|---|
System.Double[,] | The solution X from equation AX = B. |
SolveTranspose(Double[])
Solves a linear equation system of the form xA = b.
Declaration
public double[] SolveTranspose(double[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | value | The b from the equation xA = b. |
Returns
Type | Description |
---|---|
System.Double[] | The x from equation Ax = b. |
SolveTranspose(Double[,])
Solves a linear equation system of the form AX = B.
Declaration
public double[, ] SolveTranspose(double[, ] value)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | value | Parameter B from the equation AX = B. |
Returns
Type | Description |
---|---|
System.Double[,] | The solution X from equation AX = B. |