IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Stores the singular value decomposition of a matrix. More...
Public Member Functions | |
SquareMatrix | LeftTransformMatrix () |
Returns the left transform matrix. More... | |
SquareMatrix | RightTransformMatrix () |
Returns the right transform matrix. More... | |
double | SingularValue (int n) |
Gets the specificed singular value. More... | |
ColumnVector | LeftSingularVector (int n) |
Returns the specified left singular vector. More... | |
ColumnVector | RightSingularVector (int n) |
Returns the specified right singular vector. More... | |
Properties | |
int | RowCount [get] |
Gets the number of rows in the original matrix. More... | |
int | ColumnCount [get] |
Gets the number of columns in the original matrix. More... | |
int | Dimension [get] |
Gets the number of singular values. More... | |
double | ConditionNumber [get] |
Returns the condition number of the matrix. More... | |
double | Tolerance [get, set] |
Gets or sets the tolerance with which singular values are distinguished from zero. More... | |
int | Rank [get] |
Computes the rank of the original matrix. More... | |
Private Attributes | |
readonly int | rows |
readonly int | cols |
readonly double[] | utStore |
readonly double[] | wStore |
readonly double[] | vStore |
double | tolerance = Global.Accuracy |
Stores the singular value decomposition of a matrix.
The singular value decomposition of a matrix represents it as a product of a left orthogonal matrix, a diagonal matrix, and a right orthogonal matrix:
The elements of the diagonal matrix are called the singular values of the original matrix.
If the orginal matrix is viewed as a linear transform operator, the rows of the right orthogonal matrix matrix form an orthonormal basis for the domain of the operator, while the columns of the left orthogonal matrix form an orthonormal basis for the range of the operator. These rows and columns are called, respectively, the right and left singular vectors of the matrix.
The right singular vectors corresponding to zero singular values span the nullspace of the matrix, that is the set of all x for which Ax = 0.
The SVD can be used to approximate the action of a high-dimensional matrix by a lower-rank one.
Use the RectangularMatrix.SingularValueDecomposition of the RectangularMatrix class to obtain the SVD of an rectangular matrix, or the corresponding SquareMatrix.SingularValueDecomposition method of the SquareMatrix class to obtain the SVD of a square matrix.
|
inline |
Returns the left transform matrix.
References Meta.Numerics.Matrices.SquareMatrix.Transpose().
Referenced by Test.SquareMatrixTest.HilbertMatrixSVD(), Test.RectangularMatrixTest.PC(), Test.RectangularMatrixTest.RandomRectangularSVD(), and Test.RectangularMatrixTest.SmallSVD().
|
inline |
Returns the right transform matrix.
The returned matrix is read-only. If you need to make changes to it, you can call SquareMatrix.Copy to obtain a writable copy.
Referenced by Test.SquareMatrixTest.HilbertMatrixSVD(), Test.RectangularMatrixTest.PC(), Test.RectangularMatrixTest.RandomRectangularSVD(), and Test.RectangularMatrixTest.SmallSVD().
|
inline |
Gets the specificed singular value.
n | The (zero-based) index. |
ArgumentOutOfRangeException | n lies outside the range [0, Dimension - 1]. |
Referenced by Test.SquareMatrixTest.HilbertMatrixSVD(), Test.RectangularMatrixTest.PC(), Test.RectangularMatrixTest.RandomRectangularSVD(), Test.RectangularMatrixTest.SmallSVD(), and Test.SquareMatrixTest.SvdOfRankOneMatrix().
|
inline |
Returns the specified left singular vector.
n | The (zero-based) index. |
ArgumentOutOfRangeException | n lies outside the range [0, Dimension - 1]. |
The returned vector is read-only. If you need to make changes to it, you can call ColumnVector.Copy to obtain a writable copy.
Referenced by Test.RectangularMatrixTest.RandomRectangularSVD().
|
inline |
Returns the specified right singular vector.
n | The (zero-based) index. |
ArgumentOutOfRangeException | n lies outside the range [0, Dimension - 1]. |
The returned vector is read-only. If you need to make changes to it, you can call ColumnVector.Copy to obtain a writable copy.
Referenced by Test.RectangularMatrixTest.PC(), and Test.RectangularMatrixTest.RandomRectangularSVD().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
get |
Gets the number of rows in the original matrix.
Referenced by Test.RectangularMatrixTest.RandomRectangularSVD().
|
get |
Gets the number of columns in the original matrix.
Referenced by Test.RectangularMatrixTest.RandomRectangularSVD().
|
get |
Gets the number of singular values.
For a square matrix, the number of singular values is equal to the dimension of the matrix. For a rectangular matrix with more rows than columns, the number of singular values is equal to the number of columns.
Referenced by Test.SquareMatrixTest.HilbertMatrixSVD(), Test.RectangularMatrixTest.PC(), Test.RectangularMatrixTest.RandomRectangularSVD(), Test.RectangularMatrixTest.SmallSVD(), and Test.SquareMatrixTest.SvdOfRankOneMatrix().
|
get |
Returns the condition number of the matrix.
The conidition number is the ratio of the largest singular value to smallest singular value. It is therefore always larger than one.
|
getset |
Gets or sets the tolerance with which singular values are distinguished from zero.
Some operations offered by singular value decompositions, including rank determination and computation of the pseudo-inverse matrix, depend on determining whether or not a singular value is zero. Since floating point numbers are only approximate representations of real numbers, singular values will usually not be exactly zero even for matrices for which they should be, but will instead be very tiny numbers, on the order of floating point precision (about 10-16) as a fraction of the largest singular value. The value of this property is used to determine how small a singular value must be, as a fraction of the largest singular value, to be considered zero for these purposes. Usually you will want to maintain its default value.
ArgumentOutOfRangeException | The assigned value is outside the range [0,1). |
|
get |
Computes the rank of the original matrix.
The rank of a matrix is the dimension of the space of input vectors which produce non-zero output vectors upon multiplication by the original matrix.
Since this operation depends on identifying zero singular values, the result will depend on the value of the Tolerance property.