public class LUDecomposition extends Object implements Decomposition
The LUP-decomposition of a matrix A consists of three matrices L, U and P that satisfy: P×A = L×U. L is lower triangular (with unit diagonal terms), U is upper triangular and P is a permutation matrix. All matrices are m×m.
As shown by the presence of the P matrix, this decomposition is implemented using partial pivoting.
This class is based on the class with similar name from the JAMA library.
getP
method has been added,det
method has been renamed as getDeterminant
,getDoublePivot
method has been removed (but the int based getPivot
method has
been kept),solve
and isNonSingular
methods have been replaced by a getSolver
method
and the equivalent methods provided by the returned DecompositionSolver
.Constructor and Description |
---|
LUDecomposition()
Simple constructor.
|
LUDecomposition(double singularityThreshold)
Constructor used to set the singularity threshold.
|
LUDecomposition(RealMatrix matrix)
Simple constructor.
|
LUDecomposition(RealMatrix matrix,
double singularityThreshold)
Constructor used to set the singularity threshold.
|
Modifier and Type | Method and Description |
---|---|
void |
checkDecompositionPerformed()
Check decomposition has been performed.
|
void |
decompose(RealMatrix matrix)
Run the decomposition process on the input matrix.
|
double |
getDeterminant()
Return the determinant of the matrix
|
RealMatrix |
getL()
Returns the matrix L of the decomposition.
|
RealMatrix |
getP()
Returns the P rows permutation matrix.
|
int[] |
getPivot()
Returns the pivot permutation vector.
|
DecompositionSolver |
getSolver()
Gets a solver for finding the A × X = B solution in exact linear sense.
|
RealMatrix |
getU()
Returns the matrix U of the decomposition.
|
public LUDecomposition()
Once the decomposition object is built, the method decompose(RealMatrix)
needs to be called on the expected matrix to run the decomposition process before calling
any others methods. Otherwise the data won't be initialize.
NonSquareMatrixException
- if matrix is not square.LUDecomposition(double)
public LUDecomposition(double singularityThreshold)
Once the decomposition object is built, the method decompose(RealMatrix)
needs to be called on the expected matrix to run the decomposition process before calling
any others methods. Otherwise the data won't be initialize.
singularityThreshold
- threshold (based on partial row norm) under which a matrix is considered singularNonSquareMatrixException
- if matrix is not squarepublic LUDecomposition(RealMatrix matrix)
The decomposition is directly computed on the input matrix. There is no need to run the method
decompose(RealMatrix)
separately.
matrix
- The matrix to decompose.NonSquareMatrixException
- if matrix is not square.LUDecomposition(double)
public LUDecomposition(RealMatrix matrix, double singularityThreshold)
The decomposition is directly computed on the input matrix. There is no need to run the method
decompose(RealMatrix)
separately.
matrix
- The matrix to decompose.singularityThreshold
- threshold (based on partial row norm) under which a matrix is considered singularNonSquareMatrixException
- if matrix is not squarepublic void decompose(RealMatrix matrix)
Calculates the LU-decomposition of the given matrix.
decompose
in interface Decomposition
matrix
- The matrix to decompose.public RealMatrix getL()
L is a lower-triangular matrix
public RealMatrix getU()
U is an upper-triangular matrix
public RealMatrix getP()
P is a sparse matrix with exactly one element set to 1.0 in each row and each column, all other elements being set to 0.0.
The positions of the 1 elements are given by the pivot permutation vector
.
getPivot()
public int[] getPivot()
getP()
public double getDeterminant()
public DecompositionSolver getSolver()
getSolver
in interface Decomposition
public void checkDecompositionPerformed()
ArithmeticException
- thrown if decomposition has not been performed yetCopyright © 2021 CNES. All rights reserved.