The mathIT Library
A Java™ API for mathematics
org.mathIT.algebra

## Class SingularValueDecomposition

• ```public class SingularValueDecomposition
extends Object```
Singular Value Decomposition.

For an m×n matrix A with mn, the singular value decomposition is an m×n orthogonal matrix U, an n×n diagonal matrix S, and an n×n orthogonal matrix V so that A = U⋅S⋅V*.

The singular values, σ[k] = S[k][k], are ordered so that σ[0] ≥ σ[1] ≥ ... ≥ σ[n-1].

The singular value decompostion always exists, so the constructor will never fail. The matrix condition number and the effective numerical rank can be computed from this decomposition.

This class is a slight modification of the Java class by the JAMA Java Matrix Package by NIST, see http://math.nist.gov/javanumerics/jama/
Author:
JAMA, Andreas de Vries
• ### Constructor Summary

Constructors
Constructor and Description
`SingularValueDecomposition(Matrix A)`
Construct the singular value decomposition Structure to access U, S and V.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`double` `cond()`
Two norm condition number defined as the ratio max(S)/min(S) of the maximum and the minimum singular value of this matrix.
`Matrix` `getS()`
Returns the diagonal matrix S of singular values
`double[]` `getSingularValues()`
Return the one-dimensional array of singular values
`Matrix` `getU()`
Returns the left singular vectors U
`Matrix` `getV()`
Returns the right singular vectors V
`double` `norm2()`
Returns the two norm of this matrix.
`int` `rank()`
Effective numerical matrix rank
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### SingularValueDecomposition

`public SingularValueDecomposition(Matrix A)`
Construct the singular value decomposition Structure to access U, S and V.
Parameters:
`A` - a rectangular matrix with numbers of rows ≥ numbers of columns
Throws:
`IllegalArgumentException` - if number of rows < number of columns
• ### Method Detail

• #### getU

`public Matrix getU()`
Returns the left singular vectors U
Returns:
the left singular vectors U
• #### getV

`public Matrix getV()`
Returns the right singular vectors V
Returns:
the right singular vectors V
• #### getSingularValues

`public double[] getSingularValues()`
Return the one-dimensional array of singular values
Returns:
diagonal of S.
• #### getS

`public Matrix getS()`
Returns the diagonal matrix S of singular values
Returns:
the diagonal matrix S of singular values
• #### norm2

`public double norm2()`
Returns the two norm of this matrix. The two norm ||A||2 of a matrix A is defined as the value

||A||2 = max||x||=1 ||Ax||

where ||x|| is the usual Euclidean norm for vectors. In fact, ||A||2 is the maximum singular value of A.
Returns:
the two norm max(S)
• #### cond

`public double cond()`
Two norm condition number defined as the ratio max(S)/min(S) of the maximum and the minimum singular value of this matrix.
Returns:
max(S)/min(S)
• #### rank

`public int rank()`
Effective numerical matrix rank
Returns:
Number of nonnegligible singular values.