Class VisualNumerics.math.DoubleSVD
All Packages Class Hierarchy This Package Previous Next Index
Class VisualNumerics.math.DoubleSVD
java.lang.Object
|
+----VisualNumerics.math.DoubleSVD
- public class DoubleSVD
- extends Object
Singular Value Decomposition (SVD) of a
rectangular matrix of type double. We denote this orthogonal factorization
by A = U S VT.
-
DoubleSVD(double[][])
- Construct the singular value decomposition of a rectangular matrix with default tolerance.
-
DoubleSVD(double[][], double)
-
Construct the singular value decomposition of a rectangular matrix with a given tolerance.
-
info()
- Return convergence information about S, U, and V.
-
inverse()
- Compute the generalized inverse of a real matrix.
-
rank()
- Return the rank of the matrix used to construct this instance.
-
S()
- Return the singular values of the matrix used to construct this instance
in decreasing order of magnitude.
-
U()
- Return the left singular vectors resulting from the singular value
decomposition of the matrix used to construct this instance.
-
V()
-
Return the right singular vectors resulting from the singular value
decomposition of the matrix used to construct this instance.
DoubleSVD
public DoubleSVD(double aa[][],
double tol)
- Construct the singular value decomposition of a rectangular matrix with a given tolerance.
This tolerance is used to determine rank. If the DoubleSVD constructor
is called without the tol argument, the tolerance is chosen as
2.2204460492503e-14. If tol is positive, then a singular value is
considered negligible if the singular value is less than or equal to
tol. If tol is negative, then a singular value is considered negligible
if the singular value is less than or equal to the absolute value of
tol * the infinity norm of the input matrix. In the latter case, the
absolute value of tol generally contains an estimate of the level of
the relative error in the data.
- Parameters:
- aa - Input matrix of type double for which the singular value decomposition
is to be computed.
- tol - Input scalar of type double containing the tolerance used
to determine when a singular value is negligible.
- Throws: IllegalArgumentException
- This exception is issued when the row lengths of
input matrix a are not equal (i.e. the matrix edges are "jagged".)
-
Algorithm:
-
This constructor is based on the LINPACK routine DSVDC. Let n represent
the number of rows of matrix aa and let p represent the number of columns
of matrix aa. For any n x p matrix aa, there exists an n x n orthogonal
matrix U and a p x p orthogonal matrix V such that U
TAV = [S0], if n is greater than or equal to p, and UTAV = [S 0], if n is less than or equal to p. S is the diagonal matrix S = diag(s1,...,sm), where m=min(n,p). The scalars s1, s2, ...sm are called the singular values of matrix aa.
The columns of U are called the left singular vectors of matrix aa. The
columns of V are called the right singular vectors of aa.
Example:
import VisualNumerics.math.DoubleSVD;
import VisualNumerics.math.MathException;
import java.io.*;
class testDSVD {
public static void main(String args[]) {
int rank;
double s[], ainv[][];
double a[][] = {{ 1.0, 0.0},
{ 1.0, 1.0},
{100.0,-50.0}};
try {
DoubleSVD svd = new DoubleSVD(a);
s = svd.S();
rank = svd.rank();
ainv = svd.inverse();
// ... print results ...
} catch (IOException ioe) {
System.err.println(ioe.toString());
} catch (IllegalArgumentException e) {
System.err.println(e.toString());
} catch (MathException e) {
System.err.println(e.toString());
}
}
}
DoubleSVD
public DoubleSVD(double aa[][])
- Construct the singular value decomposition of a rectangular matrix with default tolerance.
The tolerance used is 2.2204460492503e-14. This tolerance is used to
determine rank. A singular value is considered negligible if the singular
value is less than or equal to this tolerance.
- Parameters:
- aa - Input matrix of type double for which the singular value decomposition
is to be computed.
- Throws: IllegalArgumentException
- This exception is issued when the row lengths of
input matrix a are not equal (i.e. the matrix edges are "jagged".)
-
Algorithm:
-
This constructor is based on the LINPACK routine DSVDC. Let n represent
the number of rows of matrix aa and let p represent the number of columns
of matrix aa. For any n x p matrix aa, there exists an n x n orthogonal
matrix U and a p x p orthogonal matrix V such that U
TAV = [S0], if n is greater than or equal to p, and UTAV = [S 0], if n is less than or equal to p. S is the diagonal matrix S = diag(s1,...,sm), where m=min(n,p). The scalars s1, s2, ...sm are called the singular values of matrix aa.
The columns of U are called the left singular vectors of matrix aa. The
columns of V
are called the right singular vectors of aa.
rank
public int rank() throws MathException
- Return the rank of the matrix used to construct this instance.
- Returns:
- An int scalar containing the rank of the matrix used to
construct this instance.
- Throws: MathException
- This exception is issued when the rank cannot be determined
because convergence was not obtained for all singular values.
-
Algorithm:
-
The DoubleSVD constructor computes the singular value decomposition of
the input matrix. The estimated rank of the input matrix is the number
of singular values which are larger than a tolerance t. If the tol used
by the constructor is greater than zero, then t = tol. If the tol used
by the constructor is less than zero, then t = (the infinity norm of input
matrix aa) * |tol|.
U
public double[][] U()
- Return the left singular vectors resulting from the singular value
decomposition of the matrix used to construct this instance.
- Returns:
- A matrix of type double containing the left singular vectors of the
matrix used to construct this instance.
V
public double[][] V()
- Return the right singular vectors resulting from the singular value
decomposition of the matrix used to construct this instance.
- Returns:
- A matrix of type double containing the right singular vectors of the
matrix used to construct this instance.
S
public double[] S()
- Return the singular values of the matrix used to construct this instance
in decreasing order of magnitude.
- Returns:
- A vector of type double containing the singular values of the
matrix used to construct this instance in decreasing order of magnitude.
info
public int info()
- Return convergence information about S, U, and V.
- Returns:
- A scalar of type int containing information which
indicates which singular values and corresponding singular
vectors reached convergence. Convergence was obtained for the
info, info+1, ..., min(nra,nca) singular values and their
corresponding vectors. Here, nra and nca represent the number
of rows and columns of the input matrix respectively.
inverse
public double[][] inverse() throws MathException
- Compute the generalized inverse of a real matrix.
- Returns:
- A matrix of type double containing the generalized inverse of the
matrix used to construct this instance.
- Throws: MathException
- This exception is issued when the rank cannot be determined
because convergence was not obtained for all singular values.
-
Algorithm:
-
This method computes the Moore-Penrose generalized inverse.
The DoubleSVD constructor is used to compute the singular value
decomposition of the input matrix. The resulting U and V matrices can
be partitioned as U = (U
1,U2) and V = (V1,V2) where
both U1 and V1
are k x k matrices. Let S1 = diag(s1,...,sm). The Moore-Penrose generalized inverse of input
matrix aa is given by V1S1-1U1T.
All Packages Class Hierarchy This Package Previous Next Index