Interface LinearSolver<T extends Matrix>
-
- All Known Subinterfaces:
- AdjustableLinearSolver
- All Known Implementing Classes:
- AdjLinearSolverQr_D64, BaseLinearSolverQrp_D64, BlockCholeskyOuterSolver, BlockQrHouseHolderSolver, LinearSolver_B64_to_D64, LinearSolverAbstract_CD64, LinearSolverAbstract_D64, LinearSolverChol_B64, LinearSolverChol_CD64, LinearSolverChol_D64, LinearSolverCholLDL_D64, LinearSolverLu_CD64, LinearSolverLu_D64, LinearSolverLuBase_CD64, LinearSolverLuBase_D64, LinearSolverLuKJI_D64, LinearSolverQr_CD64, LinearSolverQr_D64, LinearSolverQrBlock64_D64, LinearSolverQrHouse_CD64, LinearSolverQrHouse_D64, LinearSolverQrHouseCol_CD64, LinearSolverQrHouseCol_D64, LinearSolverQrHouseTran_CD64, LinearSolverQrHouseTran_D64, LinearSolverQrpHouseCol_D64, LinearSolverSafe, LinearSolverUnrolled, SolvePseudoInverseQrp_D64, SolvePseudoInverseSvd
public interface LinearSolver<T extends Matrix>An implementation of LinearSolver solves a linear system or inverts a matrix. It masks more complex implementation details, while giving the programmer control over memory management and performance. To quickly detect nearly singular matrices without computing the SVD the
quality()function is provided.A linear system is defined as: A*X = B.
where A ∈ ℜ m × n, X ∈ ℜ n × p, B ∈ ℜ m × p. Different implementations can solve different types and shapes in input matrices and have different memory and runtime performance.To solve a system:
To invert a matrix:
A matrix can also be inverted by passing in an identity matrix to solve, but this will be slower and more memory intensive than the specialized invert() function.
IMPORTANT: Depending upon the implementation, input matrices might be overwritten by the solver. This reduces memory and computational requirements and give more control to the programmer. If the input matrices need to be not modified then
LinearSolverSafecan be used. The functionsmodifiesA()andmodifiesB()specify which input matrices are being modified.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description <D extends DecompositionInterface>
DgetDecomposition()If a decomposition class was used internally then this will return that class.voidinvert(T A_inv)Computes the inverse of of the 'A' matrix passed intosetA(org.ejml.data.Matrix)and writes the results to the provided matrix.booleanmodifiesA()Returns true if the passed in matrix tosetA(org.ejml.data.Matrix)is modified.booleanmodifiesB()Returns true if the passed in 'B' matrix tosolve(org.ejml.data.Matrix, org.ejml.data.Matrix)is modified.doublequality()Returns a very quick to compute measure of how singular the system is.booleansetA(T A)Specifies the A matrix in the linear equation.voidsolve(T B, T X)Solves for X in the linear system, A*X=B.
-
-
-
Method Detail
-
setA
boolean setA(T A)
Specifies the A matrix in the linear equation. A reference might be saved and it might also be modified depending on the implementation. If it is modified then
modifiesA()will return true.If this value returns true that does not guarantee a valid solution was generated. This is because some decompositions don't detect singular matrices.
- Parameters:
A- The 'A' matrix in the linear equation. Might be modified or save the reference.- Returns:
- true if it can be processed.
-
quality
double quality()
Returns a very quick to compute measure of how singular the system is. This measure will be invariant to the scale of the matrix and always be positive, with larger values indicating it is less singular. If not supported by the solver then the runtime exception IllegalArgumentException is thrown. This is NOT the matrix's condition.
How this function is implemented is not specified. One possible implementation is the following: In many decompositions a triangular matrix is extracted. The determinant of a triangular matrix is easily computed and once normalized to be scale invariant and its absolute value taken it will provide functionality described above.
- Returns:
- The quality of the linear system.
-
solve
void solve(T B, T X)
Solves for X in the linear system, A*X=B.
In some implementations 'B' and 'X' can be the same instance of a variable. Call
modifiesB()to determine if 'B' is modified.- Parameters:
B- A matrix ℜ m × p. Might be modified.X- A matrix ℜ n × p, where the solution is written to. Modified.
-
invert
void invert(T A_inv)
Computes the inverse of of the 'A' matrix passed intosetA(org.ejml.data.Matrix)and writes the results to the provided matrix. If 'A_inv' needs to be different from 'A' is implementation dependent.- Parameters:
A_inv- Where the inverted matrix saved. Modified.
-
modifiesA
boolean modifiesA()
Returns true if the passed in matrix tosetA(org.ejml.data.Matrix)is modified.- Returns:
- true if A is modified in setA().
-
modifiesB
boolean modifiesB()
Returns true if the passed in 'B' matrix tosolve(org.ejml.data.Matrix, org.ejml.data.Matrix)is modified.- Returns:
- true if B is modified in solve(B,X).
-
getDecomposition
<D extends DecompositionInterface> D getDecomposition()
If a decomposition class was used internally then this will return that class. Most linear solvers decompose the input matrix into a more simplistic form. However some solutions do not require decomposition, e.g. inverse by minor.- Type Parameters:
D- Decomposition type- Returns:
- Internal decomposition class. If there is none then null.
-
-
DMelt 3.0 © DataMelt by jWork.ORG