Class SVD
double.
SVD is based on the LINPACK routine SSVDC; see
Dongarra et al. (1979).
Let n be the number of rows in A
and let p be the number of columns in
A. For any
n x p matrix
A, there exists an n x n
orthogonal matrix U and a p x p
orthogonal matrix V such that
$$U^T A V = \left\{ \begin{array}{cl} \left[ \begin{array}{l} \Sigma \\ 0 \end{array} \right] & \mbox{if $n \ge p$} \\ \left[ \Sigma \,\, 0 \right] & \mbox{if $n \le p$} \end{array} \right.$$
where \(\Sigma = {\rm diag}(\sigma_1, \ldots, \sigma_m)\), and \(m = \min(n, p)\). The scalars \(\sigma_1 \geq \sigma_2 \geq \ldots \geq \sigma_m \geq 0\) are called the singular values of A. The columns of U are called the left singular vectors of A. The columns of V are called the right singular vectors of A.
The estimated rank of A is the number of
\(\sigma_k\) that is larger than a tolerance \(\eta\).
If \(\tau\) is the parameter tol in the
program, then
$$\eta = \left\{ \begin{array}{cl} \tau \hfill & \mbox {if $\tau \gt 0$} \\ {\left| \tau \right|\left\| A \right\|_\infty } \hfill & \mbox {if $\tau \lt 0$} \end{array} \right.$$
The Moore-Penrose generalized inverse of the matrix is computed by partitioning the matrices U, V and \(\Sigma\) as \(U = (U_1,U_2)\), \(V = (V_1,V_2)\) and \(\Sigma_1 = {\rm diag}(\sigma_1,\ldots,\sigma_k)\) where the "1" matrices are k by k. The Moore-Penrose generalized inverse is \(V_1 \Sigma_1^{-1} U_1^T\).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe iteration did not converge -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetInfo()Returns convergence information about S, U, and V.double[][]Compute the Moore-Penrose generalized inverse.intgetRank()Returns the rank of the matrix used to construct this instance.double[]getS()Returns the singular values.double[][]getU()Returns the left singular vectors.double[][]getV()Returns the right singular vectors.double[][]inverse()Deprecated.Method name does not adhere to the Java naming conventions.
-
Constructor Details
-
SVD
Construct the singular value decomposition of a rectangular matrix with a given tolerance. Iftolis positive, then a singular value is considered negligible if the singular value is less than or equal totol. Iftolis negative, then a singular value is considered negligible if the singular value is less than or equal to the absolute value of the product oftoland the infinity norm of the input matrix. In the latter case, the absolute value oftolgenerally contains an estimate of the level of the relative error in the data.- Parameters:
a- adoublematrix for which the singular value decomposition is to be computedtol- adoublescalar containing the tolerance used to determine when a singular value is negligible- Throws:
IllegalArgumentException- is thrown when the row lengths of input matrix a are not equal (for example, the matrix edges are "jagged")SVD.DidNotConvergeException- is thrown when the rank cannot be determined because convergence was not obtained for all singular values
-
SVD
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:
a- adoublematrix for which the singular value decomposition is to be computed- Throws:
IllegalArgumentException- is thrown when the row lengths of input matrix a are not equal (i.e. the matrix edges are "jagged")SVD.DidNotConvergeException
-
-
Method Details
-
getRank
public int getRank()Returns the rank of the matrix used to construct this instance.- Returns:
- an
intscalar containing the rank of the matrix used to construct this instance. The estimated rank of the input matrix is the number of singular values which are larger than a tolerance.
-
getU
public double[][] getU()Returns the left singular vectors.- Returns:
- a
doublematrix containing the left singular vectors
-
getV
public double[][] getV()Returns the right singular vectors.- Returns:
- a
doublematrix containing the right singular vectors
-
getS
public double[] getS()Returns the singular values.- Returns:
- a
doublearray containing the singular values of the matrix
-
getInfo
public int getInfo()Returns convergence information about S, U, and V.- Returns:
- 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
Deprecated.Method name does not adhere to the Java naming conventions. UsegetInverse()instead.Compute the Moore-Penrose generalized inverse of a real matrix.- Returns:
- a
doublematrix containing the generalized inverse of the matrix used to construct this instance
-
getInverse
public double[][] getInverse()Compute the Moore-Penrose generalized inverse.- Returns:
- a
doublematrix containing the generalized inverse of the matrix used to construct this instance
-