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>

You create instances of (some subclass of) this class by calling one of the static factory methods: makeBig(), makeComplex(), makePrimitive(), makeAlternative() or makeJama().

Author:
apete

Method Summary
 boolean compute(Access2D<?> aMtrx)
           
 boolean compute(Access2D<?> aMtrx, boolean singularValuesOnly)
           
 boolean equals(MatrixDecomposition<N> aDecomp, NumberContext aCntxt)
           
 boolean equals(Object someObj)
           
 double getCondition()
          The condition number.
 MatrixStore<N> getD()
           
 double 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".
 MatrixStore<N> getInverse(DecompositionStore<N> preallocated)
           Implementiong this method is optional.
 double getKyFanNorm(int k)
           Ky Fan k-norm.
 double getOperatorNorm()
           
 MatrixStore<N> getQ1()
           
 MatrixStore<N> getQ2()
           
 int getRank()
          Effective numerical matrix rank.
 Array1D<Double> getSingularValues()
           
 double getTraceNorm()
           
 boolean isAspectRatioNormal()
           
 boolean isComputed()
           
static
<N extends Number>
SingularValue<N>
make(Access2D<N> aTypical)
           
static SingularValue<Double> makeAlternative()
           
static SingularValue<BigDecimal> makeBig()
           
static SingularValue<ComplexNumber> makeComplex()
           
static SingularValue<Double> makeJama()
           
static SingularValue<Double> makePrimitive()
           
 MatrixStore<N> reconstruct()
           
 void reset()
          Delete computed results, and resets attributes to default values
 MatrixStore<N> solve(MatrixStore<N> aRHS)
          [A][X]=[B] or [this][return]=[aRHS]
 MatrixStore<N> solve(MatrixStore<N> aRHS, DecompositionStore<N> preallocated)
           Implementiong this method is optional.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ojalgo.matrix.decomposition.SingularValue
isOrdered
 
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
equals, equals, isComputed, isFullSize, isSolvable
 

Method Detail

make

public static final <N extends Number> SingularValue<N> make(Access2D<N> aTypical)

makeAlternative

public static final SingularValue<Double> makeAlternative()

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(Access2D<?> aMtrx)
Specified by:
compute in interface MatrixDecomposition<N extends Number & Comparable<N>>
Parameters:
aMtrx - A matrix to decompose
Returns:
true if the computation suceeded; false if not

compute

public boolean compute(Access2D<?> aMtrx,
                       boolean singularValuesOnly)
Specified by:
compute in interface SingularValue<N extends Number & Comparable<N>>
Parameters:
aMtrx - A matrix to decompose
singularValuesOnly - No need to calculate eigenvectors
Returns:
true/false if the computation succeeded or not

getCondition

public final double 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.

getFrobeniusNorm

public final double 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()

getInverse

public final MatrixStore<N> getInverse(DecompositionStore<N> preallocated)
Description copied from interface: MatrixDecomposition

Implementiong this method is optional.

Exactly how a specific implementation makes use of preallocated is not specified by this interface. It must be documented for each implementation.

Should produce the same results as calling MatrixDecomposition.getInverse().

Specified by:
getInverse in interface MatrixDecomposition<N extends Number & Comparable<N>>
Parameters:
preallocated - Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/final/correct solution.
Returns:
The inverse

getKyFanNorm

public final double 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.

getOperatorNorm

public final double getOperatorNorm()
Specified by:
getOperatorNorm in interface SingularValue<N extends Number & Comparable<N>>
Returns:
2-norm

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 Array1D<Double> getSingularValues()
Specified by:
getSingularValues in interface SingularValue<N extends Number & Comparable<N>>
Returns:
The singular values ordered in descending order.

getTraceNorm

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

isAspectRatioNormal

public final boolean isAspectRatioNormal()

reconstruct

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

reset

public void reset()
Description copied from interface: MatrixDecomposition
Delete computed results, and resets attributes to default values

Specified by:
reset in interface MatrixDecomposition<N extends Number & Comparable<N>>

solve

public MatrixStore<N> solve(MatrixStore<N> aRHS)
Description copied from interface: MatrixDecomposition
[A][X]=[B] or [this][return]=[aRHS]

Specified by:
solve in interface MatrixDecomposition<N extends Number & Comparable<N>>

solve

public MatrixStore<N> solve(MatrixStore<N> aRHS,
                            DecompositionStore<N> preallocated)
Description copied from interface: MatrixDecomposition

Implementiong this method is optional.

Exactly how a specific implementation makes use of preallocated is not specified by this interface. It must be documented for each implementation.

Should produce the same results as calling MatrixDecomposition.solve(MatrixStore).

Specified by:
solve in interface MatrixDecomposition<N extends Number & Comparable<N>>
Parameters:
aRHS - The Right Hand Side, wont be modfied
preallocated - Preallocated memory for the results, possibly some intermediate results. You must assume this is modified, but you cannot assume it will contain the full/final/correct solution.
Returns:
The solution

equals

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

equals

public boolean equals(Object someObj)
Overrides:
equals in class Object

isComputed

public final 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(Access2D), MatrixDecomposition.isSolvable()