org.apache.commons.math.linear
Class SingularValueDecompositionImpl.Solver

java.lang.Object
  extended by org.apache.commons.math.linear.SingularValueDecompositionImpl.Solver
All Implemented Interfaces:
DecompositionSolver
Enclosing class:
SingularValueDecompositionImpl

private static class SingularValueDecompositionImpl.Solver
extends java.lang.Object
implements DecompositionSolver

Specialized solver.


Field Summary
private  boolean nonSingular
          Singularity indicator.
private  double[] singularValues
          Singular values.
private  RealMatrix uT
          UT matrix of the decomposition.
private  RealMatrix v
          V matrix of the decomposition.
 
Constructor Summary
private SingularValueDecompositionImpl.Solver(double[] singularValues, RealMatrix uT, RealMatrix v, boolean nonSingular)
          Build a solver from decomposed matrix.
 
Method Summary
 RealMatrix getInverse()
          Get the pseudo-inverse of the decomposed matrix.
 boolean isNonSingular()
          Check if the decomposed matrix is non-singular.
 double[] solve(double[] b)
          Solve the linear equation A × X = B in least square sense.
 RealMatrix solve(RealMatrix b)
          Solve the linear equation A × X = B in least square sense.
 RealVector solve(RealVector b)
          Solve the linear equation A × X = B in least square sense.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singularValues

private final double[] singularValues
Singular values.


uT

private final RealMatrix uT
UT matrix of the decomposition.


v

private final RealMatrix v
V matrix of the decomposition.


nonSingular

private boolean nonSingular
Singularity indicator.

Constructor Detail

SingularValueDecompositionImpl.Solver

private SingularValueDecompositionImpl.Solver(double[] singularValues,
                                              RealMatrix uT,
                                              RealMatrix v,
                                              boolean nonSingular)
Build a solver from decomposed matrix.

Parameters:
singularValues - singularValues
uT - UT matrix of the decomposition
v - V matrix of the decomposition
nonSingular - singularity indicator
Method Detail

solve

public double[] solve(double[] b)
               throws java.lang.IllegalArgumentException,
                      InvalidMatrixException
Solve the linear equation A × X = B in least square sense.

The m×n matrix A may not be square, the solution X is such that ||A × X - B|| is minimal.

Specified by:
solve in interface DecompositionSolver
Parameters:
b - right-hand side of the equation A × X = B
Returns:
a vector X that minimizes the two norm of A × X - B
Throws:
java.lang.IllegalArgumentException - if matrices dimensions don't match
InvalidMatrixException - if decomposed matrix is singular

solve

public RealVector solve(RealVector b)
                 throws java.lang.IllegalArgumentException,
                        InvalidMatrixException
Solve the linear equation A × X = B in least square sense.

The m×n matrix A may not be square, the solution X is such that ||A × X - B|| is minimal.

Specified by:
solve in interface DecompositionSolver
Parameters:
b - right-hand side of the equation A × X = B
Returns:
a vector X that minimizes the two norm of A × X - B
Throws:
java.lang.IllegalArgumentException - if matrices dimensions don't match
InvalidMatrixException - if decomposed matrix is singular

solve

public RealMatrix solve(RealMatrix b)
                 throws java.lang.IllegalArgumentException,
                        InvalidMatrixException
Solve the linear equation A × X = B in least square sense.

The m×n matrix A may not be square, the solution X is such that ||A × X - B|| is minimal.

Specified by:
solve in interface DecompositionSolver
Parameters:
b - right-hand side of the equation A × X = B
Returns:
a matrix X that minimizes the two norm of A × X - B
Throws:
java.lang.IllegalArgumentException - if matrices dimensions don't match
InvalidMatrixException - if decomposed matrix is singular

isNonSingular

public boolean isNonSingular()
Check if the decomposed matrix is non-singular.

Specified by:
isNonSingular in interface DecompositionSolver
Returns:
true if the decomposed matrix is non-singular

getInverse

public RealMatrix getInverse()
                      throws InvalidMatrixException
Get the pseudo-inverse of the decomposed matrix.

Specified by:
getInverse in interface DecompositionSolver
Returns:
inverse matrix
Throws:
InvalidMatrixException - if decomposed matrix is singular


Copyright (c) 2003-2009 Apache Software Foundation