org.ojalgo.matrix.jama
Class JamaSingularValue

java.lang.Object
  extended by org.ojalgo.matrix.jama.JamaSingularValue
All Implemented Interfaces:
MatrixDecomposition<Double>, SingularValue<Double>

public final class JamaSingularValue
extends Object
implements SingularValue<Double>

This class adapts JAMA's SingularValueDecomposition to ojAlgo's SingularValue interface.

Author:
apete

Constructor Summary
JamaSingularValue()
           
 
Method Summary
 boolean compute(MatrixStore<Double> aStore)
           
 boolean equals(BasicMatrix aMtrx, NumberContext aCntxt)
           
 boolean equals(MatrixDecomposition<Double> aDecomp, NumberContext aCntxt)
           
 boolean equals(MatrixStore<Double> aStore, NumberContext aCntxt)
           
 double getCondition()
          The condition number.
 JamaMatrix getD()
           
 double getFrobeniusNorm()
          Sometimes also called the Schatten 2-norm or Hilbert-Schmidt norm.
 JamaMatrix getInverse()
          The output must be a "right inverse" and a "generalised inverse".
 double getKyFanNorm(int k)
           Ky Fan k-norm.
 double getOperatorNorm()
           
 JamaMatrix getQ1()
           
 JamaMatrix getQ2()
           
 int getRank()
          Effective numerical matrix rank.
 Array1D<Double> getSingularValues()
           
 double getTraceNorm()
           
 JamaMatrix invert(MatrixStore<Double> 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 isOrdered()
           
 boolean isSolvable()
           
 boolean isSorted()
          Deprecated. Use isOrdered() instead
 void reset()
           
 JamaMatrix solve(MatrixStore<Double> aRHS)
          Internally this implementation uses the pseudoinverse that is recreated with every call.
 Future<DecomposeAndSolve<Double>> solve(MatrixStore<Double> aBody, MatrixStore<Double> aRHS)
          Will solve [aBody][X]=[aRHS] concurrently by first calling MatrixDecomposition.compute(MatrixStore) using [aBody], and then MatrixDecomposition.solve(MatrixStore) using [aRHS].
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ojalgo.matrix.decomposition.MatrixDecomposition
compute, equals, invert, solve
 

Constructor Detail

JamaSingularValue

public JamaSingularValue()
Method Detail

equals

public boolean equals(MatrixStore<Double> aStore,
                      NumberContext aCntxt)
Specified by:
equals in interface MatrixDecomposition<Double>

getCondition

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

Specified by:
getCondition in interface SingularValue<Double>
Returns:
The largest singular value divided by the smallest singular value.

getD

public JamaMatrix getD()
Specified by:
getD in interface SingularValue<Double>
Returns:
The diagonal matrix of singular values.

getFrobeniusNorm

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

Specified by:
getFrobeniusNorm in interface SingularValue<Double>
Returns:
The square root of the sum of squares of the singular values.

getInverse

public JamaMatrix getInverse()
Description copied from interface: MatrixDecomposition
The output must be a "right inverse" and a "generalised inverse".

Specified by:
getInverse in interface MatrixDecomposition<Double>
See Also:
BasicMatrix.invert()

getKyFanNorm

public 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<Double>
Parameters:
k - The number of singular values to add up.
Returns:
The sum of the k largest singular values.

getOperatorNorm

public double getOperatorNorm()
Specified by:
getOperatorNorm in interface SingularValue<Double>

getQ1

public JamaMatrix getQ1()
Specified by:
getQ1 in interface SingularValue<Double>

getQ2

public JamaMatrix getQ2()
Specified by:
getQ2 in interface SingularValue<Double>

getRank

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

Specified by:
getRank in interface SingularValue<Double>
Returns:
The number of nonnegligible singular values.

getSingularValues

public Array1D<Double> getSingularValues()
Specified by:
getSingularValues in interface SingularValue<Double>
Returns:
The singular values ordered in descending order.

getTraceNorm

public double getTraceNorm()
Specified by:
getTraceNorm in interface SingularValue<Double>

isComputed

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

isFullSize

public boolean isFullSize()
Specified by:
isFullSize in interface MatrixDecomposition<Double>
Returns:
True if the implementation generates a full sized decomposition.

isSolvable

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

isSorted

public boolean isSorted()
Deprecated. Use isOrdered() instead

Specified by:
isSorted in interface SingularValue<Double>

isOrdered

public boolean isOrdered()
Specified by:
isOrdered in interface SingularValue<Double>

reset

public void reset()
Specified by:
reset in interface MatrixDecomposition<Double>

solve

public JamaMatrix solve(MatrixStore<Double> aRHS)
Internally this implementation uses the pseudoinverse that is recreated with every call.

Specified by:
solve in interface MatrixDecomposition<Double>

toString

public String toString()
Overrides:
toString in class Object

compute

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

equals

public final boolean equals(BasicMatrix aMtrx,
                            NumberContext aCntxt)

equals

public boolean equals(MatrixDecomposition<Double> aDecomp,
                      NumberContext aCntxt)
Specified by:
equals in interface MatrixDecomposition<Double>

invert

public final JamaMatrix invert(MatrixStore<Double> 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<Double>

solve

public final Future<DecomposeAndSolve<Double>> solve(MatrixStore<Double> aBody,
                                                     MatrixStore<Double> 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<Double>
Parameters:
aBody - The equation system body
aRHS - The equation system right hand side
Returns:
The matrix decomposition and the equation system solution, [X]