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. speed: 52.641s

Author:
apete

Constructor Summary
JamaSingularValue()
          Not recommended to use this constructor directly.
 
Method Summary
 boolean compute(Access2D<?> aStore)
           
 boolean compute(Access2D<?> aMtrx, boolean singularValuesOnly)
           
 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".
 MatrixStore<Double> getInverse(DecompositionStore<Double> preallocated)
          Makes no use of preallocated at all.
 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)
           
 boolean isAspectRatioNormal()
           
 boolean isComputed()
           
 boolean isFullSize()
           
 boolean isOrdered()
           
 boolean isSolvable()
           
 MatrixStore<Double> reconstruct()
           
 void reset()
          Delete computed results, and resets attributes to default values
 JamaMatrix solve(MatrixStore<Double> aRHS)
          Internally this implementation uses the pseudoinverse that is recreated with every call.
 JamaMatrix solve(MatrixStore<Double> aRHS, DecompositionStore<Double> preallocated)
          Makes no use of preallocated at all.
 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, getInverse, solve
 

Constructor Detail

JamaSingularValue

public JamaSingularValue()
Not recommended to use this constructor directly. Consider using the static factory method SingularValueDecomposition.makeJama() instead.

Method Detail

compute

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

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>
Returns:
2-norm

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>

isAspectRatioNormal

public boolean isAspectRatioNormal()

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

isFullSize

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

isOrdered

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

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()

reconstruct

public MatrixStore<Double> reconstruct()
Specified by:
reconstruct in interface MatrixDecomposition<Double>

reset

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

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(Access2D<?> 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(MatrixDecomposition<Double> aDecomp,
                            NumberContext aCntxt)
Specified by:
equals in interface MatrixDecomposition<Double>

getInverse

public final MatrixStore<Double> getInverse(DecompositionStore<Double> preallocated)
Makes no use of preallocated at all. Simply delegates to getInverse().

Specified by:
getInverse in interface MatrixDecomposition<Double>
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
See Also:
MatrixDecomposition.getInverse(org.ojalgo.matrix.decomposition.DecompositionStore)

invert

public final JamaMatrix invert(MatrixStore<Double> aStore)

solve

public final JamaMatrix solve(MatrixStore<Double> aRHS,
                              DecompositionStore<Double> preallocated)
Makes no use of preallocated at all. Simply delegates to solve(MatrixStore).

Specified by:
solve in interface MatrixDecomposition<Double>
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
See Also:
MatrixDecomposition.solve(org.ojalgo.matrix.store.MatrixStore, org.ojalgo.matrix.decomposition.DecompositionStore)