## Interface SingularValueDecomposition<T extends Matrix64F>

- All Superinterfaces:
- DecompositionInterface<T>

- All Known Implementing Classes:
- SafeSvd, SvdImplicitQrDecompose

public interface SingularValueDecomposition<T extends Matrix64F>extends DecompositionInterface<T>

This is an abstract class for computing the singular value decomposition (SVD) of a matrix, which is defined as:

A = U * W * V^{T}

where A is m by n, and U and V are orthogonal matrices, and W is a diagonal matrix.The dimension of U,W,V depends if it is a compact SVD or not. If not compact then U is m by m, W is m by n, V is n by n. If compact then let s be the number of singular values, U is m by s, W is s by s, and V is n by s.

Accessor functions for decomposed matrices can return an internally constructed matrix if null is passed in for the optional storage parameter. The exact behavior is implementation specific. If an internally maintained matrix is returned then on the next call to decompose the matrix will be modified. The advantage of this approach is reduced memory overhead.

To create a new instance of SingularValueDecomposition see

`DecompositionFactory.svd(int, int, boolean, boolean, boolean)`

and`SingularOps`

contains additional helpful SVD related functions.***Note***that the ordering of singular values is not guaranteed, unless done so by a specific implementation. The singular values can be put into descending order while adjusting U and V using`SingularOps.descendingOrder(org.ejml.data.DenseMatrix64F, boolean, org.ejml.data.DenseMatrix64F, org.ejml.data.DenseMatrix64F, boolean)`

SingularOps.descendingOrder()}.

### Method Summary

Methods Modifier and Type Method and Description `double[]`

**getSingularValues**()Returns the singular values.`T`

**getU**(T U, boolean transposed)Returns the orthogonal 'U' matrix.`T`

**getV**(T V, boolean transposed)Returns the orthogonal 'V' matrix.`T`

**getW**(T W)Returns a diagonal matrix with the singular values.`boolean`

**isCompact**()If true then compact matrices are returned.`int`

**numberOfSingularValues**()The number of singular values in the matrix.`int`

**numCols**()Number of columns in the decomposed matrix.`int`

**numRows**()Number of rows in the decomposed matrix.### Methods inherited from interface org.ejml.factory.DecompositionInterface

`decompose, inputModified`

### Method Detail

#### getSingularValues

double[] getSingularValues()

Returns the singular values. This is the diagonal elements of the W matrix in the decomposition.**Ordering of singular values is not guaranteed.**.- Returns:
- Singular values. Note this array can be longer than the number of singular values. Extra elements have no meaning.

#### numberOfSingularValues

int numberOfSingularValues()

The number of singular values in the matrix. This is equal to the length of the smallest side.- Returns:
- Number of singular values in the matrix.

#### isCompact

boolean isCompact()

If true then compact matrices are returned.- Returns:
- true if results use compact notation.

#### getU

T getU(T U, boolean transposed)

Returns the orthogonal 'U' matrix.

Internally the SVD algorithm might compute U transposed or it might not. To avoid an unnecessary double transpose the option is provided to select if the transpose is returned.

- Parameters:
`U`

- Optional storage for U. If null a new instance or internally maintained matrix is returned. Modified.`transposed`

- If the returned U is transposed.- Returns:
- An orthogonal matrix.

#### getV

T getV(T V, boolean transposed)

Returns the orthogonal 'V' matrix.

Internally the SVD algorithm might compute V transposed or it might not. To avoid an unnecessary double transpose the option is provided to select if the transpose is returned.

- Parameters:
`V`

- Optional storage for v. If null a new instance or internally maintained matrix is returned. Modified.`transposed`

- If the returned V is transposed.- Returns:
- An orthogonal matrix.

#### getW

T getW(T W)

Returns a diagonal matrix with the singular values. Order of the singular values is not guaranteed.- Parameters:
`W`

- Optional storage for W. If null a new instance or internally maintained matrix is returned. Modified.- Returns:
- Diagonal matrix with singular values along the diagonal.

#### numRows

int numRows()

Number of rows in the decomposed matrix.- Returns:
- Number of rows in the decomposed matrix.

#### numCols

int numCols()

Number of columns in the decomposed matrix.- Returns:
- Number of columns in the decomposed matrix.

**SCaVis 1.8 © jWork.org**