org.ojalgo.matrix.decomposition
Class SingularValueDecomposition<N extends Number & Comparable<N>>

java.lang.Object
  extended by org.ojalgo.matrix.decomposition.SingularValueDecomposition<N>
All Implemented Interfaces:
MatrixDecomposition<N>, SingularValue<N>

public abstract class SingularValueDecomposition<N extends Number & Comparable<N>>
extends Object
implements SingularValue<N>


Nested Class Summary
static class SingularValueDecomposition.RotateRight<N extends Number>
           
 
Method Summary
 boolean compute(MatrixStore<N> aStore)
           
 boolean equals(BasicMatrix aMtrx, NumberContext aCntxt)
           
 boolean equals(MatrixStore<N> aStore, NumberContext aCntxt)
           
 N getCondition()
          The condition number.
 MatrixStore<N> getD()
           
 int[] getFilter(N aLimit)
           
 N getFrobeniusNorm()
          Sometimes also called the Schatten 2-norm or Hilbert-Schmidt norm.
 MatrixStore<N> getInverse()
          The output must be a "right inverse" and a "generalised inverse".
 N getKyFanNorm(int k)
           Ky Fan k-norm.
 MatrixStore<N> getQ1()
           
 MatrixStore<N> getQ2()
           
 int getRank()
          Effective numerical matrix rank.
 Array1Dim<N> getSingularValues()
           
 MatrixStore<N> invert(MatrixStore<N> aStore)
          A convenience method that produces exactly the same result as if you first call MatrixDecomposition.compute(MatrixStore) and then MatrixDecomposition.getInverse().
 boolean isComputed()
           
 boolean isFullSize()
           
 boolean isSolvable()
           
static SingularValue<BigDecimal> makeBig()
           
static SingularValue<ComplexNumber> makeComplex()
           
static SingularValue<Double> makeJama()
           
static SingularValue<Double> makePrimitive()
           
 void reset()
           
 MatrixStore<N> solve(MatrixStore<N> aRHS)
           
 Future<DecomposeAndSolve<N>> solve(MatrixStore<N> aBody, MatrixStore<N> aRHS)
          Will solve [aBody][X]=[aRHS] concurrently by first calling MatrixDecomposition.compute(MatrixStore) using [aBody], and then MatrixDecomposition.solve(MatrixStore) using [aRHS].
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
equals, invert, isComputed, solve
 

Method Detail

makeBig

public static final SingularValue<BigDecimal> makeBig()

makeComplex

public static final SingularValue<ComplexNumber> makeComplex()

makeJama

public static final SingularValue<Double> makeJama()

makePrimitive

public static final SingularValue<Double> makePrimitive()

compute

public final boolean compute(MatrixStore<N> aStore)
Specified by:
compute in interface MatrixDecomposition<N extends Number & Comparable<N>>
Parameters:
aStore - A matrix to decompose
Returns:
true if the computation suceeded; false if not

equals

public final boolean equals(MatrixStore<N> aStore,
                            NumberContext aCntxt)
Specified by:
equals in interface MatrixDecomposition<N extends Number & Comparable<N>>

getCondition

public final N getCondition()
Description copied from interface: SingularValue
The condition number.

Specified by:
getCondition in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The largest singular value divided by the smallest singular value.

getD

public final MatrixStore<N> getD()
Specified by:
getD in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The diagonal matrix of singular values.

getFilter

public int[] getFilter(N aLimit)

getFrobeniusNorm

public final N getFrobeniusNorm()
Description copied from interface: SingularValue
Sometimes also called the Schatten 2-norm or Hilbert-Schmidt norm.

Specified by:
getFrobeniusNorm in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The square root of the sum of squares of the singular values.

getInverse

public final MatrixStore<N> getInverse()
Description copied from interface: MatrixDecomposition
The output must be a "right inverse" and a "generalised inverse".

Specified by:
getInverse in interface MatrixDecomposition<N extends Number & Comparable<N>>
See Also:
BasicMatrix.invert()

getKyFanNorm

public final N getKyFanNorm(int k)
Description copied from interface: SingularValue

Ky Fan k-norm.

The first Ky Fan k-norm is the operator norm (the largest singular value), and the last is called the trace norm (the sum of all singular values).

Specified by:
getKyFanNorm in interface SingularValue<N extends Number & Comparable<N>>
Parameters:
k - The number of singular values to add up.
Returns:
The sum of the k largest singular values.

getQ1

public final MatrixStore<N> getQ1()
Specified by:
getQ1 in interface SingularValue<N extends Number & Comparable<N>>

getQ2

public final MatrixStore<N> getQ2()
Specified by:
getQ2 in interface SingularValue<N extends Number & Comparable<N>>

getRank

public final int getRank()
Description copied from interface: SingularValue
Effective numerical matrix rank.

Specified by:
getRank in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The number of nonnegligible singular values.

getSingularValues

public final Array1Dim<N> getSingularValues()
Specified by:
getSingularValues in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The singular values ordered in descending order.

isFullSize

public final boolean isFullSize()
Specified by:
isFullSize in interface MatrixDecomposition<N extends Number & Comparable<N>>
Returns:
True if the implementation generates a full sized decomposition.

isSolvable

public boolean isSolvable()
Specified by:
isSolvable in interface MatrixDecomposition<N extends Number & Comparable<N>>
Returns:
true if it is ok to call MatrixDecomposition.solve(MatrixStore) (computation was successful); false if not
See Also:
MatrixDecomposition.solve(MatrixStore), MatrixDecomposition.isComputed()

reset

public final void reset()
Specified by:
reset in interface MatrixDecomposition<N extends Number & Comparable<N>>

solve

public final MatrixStore<N> solve(MatrixStore<N> aRHS)
Specified by:
solve in interface MatrixDecomposition<N extends Number & Comparable<N>>

equals

public boolean equals(BasicMatrix aMtrx,
                      NumberContext aCntxt)
Specified by:
equals in interface MatrixDecomposition<N extends Number>

invert

public final MatrixStore<N> invert(MatrixStore<N> aStore)
Description copied from interface: MatrixDecomposition
A convenience method that produces exactly the same result as if you first call MatrixDecomposition.compute(MatrixStore) and then MatrixDecomposition.getInverse().

Specified by:
invert in interface MatrixDecomposition<N extends Number>

isComputed

public boolean isComputed()
Specified by:
isComputed in interface MatrixDecomposition<N extends Number>
Returns:
true if computation has been attemped; false if not.
See Also:
MatrixDecomposition.compute(MatrixStore), MatrixDecomposition.isSolvable()

solve

public Future<DecomposeAndSolve<N>> solve(MatrixStore<N> aBody,
                                          MatrixStore<N> aRHS)
Description copied from interface: MatrixDecomposition
Will solve [aBody][X]=[aRHS] concurrently by first calling MatrixDecomposition.compute(MatrixStore) using [aBody], and then MatrixDecomposition.solve(MatrixStore) using [aRHS]. If either of the input [aBody] or [aRHS] is set to null the corresponing calculation is skipped.

Specified by:
solve in interface MatrixDecomposition<N extends Number>
Parameters:
aBody - The equation system body
aRHS - The equation system right hand side
Returns:
The matrix decomposition and the equation system solution, [X]