Class SingularValueDecomposition.Solver
java.lang.Object
org.apache.commons.math3.linear.SingularValueDecomposition.Solver
- All Implemented Interfaces:
DecompositionSolver
- Enclosing class:
SingularValueDecomposition
private static class SingularValueDecomposition.Solver
extends Object
implements DecompositionSolver
Specialized solver.
- Since:
- 2.0 (changed to concrete class in 3.0)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanSingularity indicator.private final RealMatrixPseudo-inverse of the initial matrix. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSolver(double[] singularValues, RealMatrix uT, RealMatrix v, boolean nonSingular, double tol) Build a solver from decomposed matrix. -
Method Summary
Modifier and TypeMethodDescriptionGet the pseudo-inverse of the decomposed matrix.booleanCheck if the decomposed matrix is non-singular.solve(RealMatrix b) Solve the linear equation A × X = B in least square sense.solve(RealVector b) Solve the linear equation A × X = B in least square sense.
-
Field Details
-
pseudoInverse
Pseudo-inverse of the initial matrix. -
nonSingular
private boolean nonSingularSingularity indicator.
-
-
Constructor Details
-
Solver
private Solver(double[] singularValues, RealMatrix uT, RealMatrix v, boolean nonSingular, double tol) Build a solver from decomposed matrix.- Parameters:
singularValues- Singular values.uT- UT matrix of the decomposition.v- V matrix of the decomposition.nonSingular- Singularity indicator.tol- tolerance for singular values
-
-
Method Details
-
solve
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:
solvein interfaceDecompositionSolver- 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:
DimensionMismatchException- if the matrices dimensions do not match.
-
solve
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:
solvein interfaceDecompositionSolver- 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:
DimensionMismatchException- if the matrices dimensions do not match.
-
isNonSingular
public boolean isNonSingular()Check if the decomposed matrix is non-singular.- Specified by:
isNonSingularin interfaceDecompositionSolver- Returns:
trueif the decomposed matrix is non-singular.
-
getInverse
Get the pseudo-inverse of the decomposed matrix.- Specified by:
getInversein interfaceDecompositionSolver- Returns:
- the inverse matrix.
-