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.| Modifier and Type | Class and Description |
|---|---|
| private static class | LUDecomposition.
Specialized solver. |
| Modifier and Type | Field and Description |
|---|---|
| private RealMatrix | cachedL
Cached value of L. |
| private RealMatrix | cachedP
Cached value of P. |
| private RealMatrix | cachedU
Cached value of U. |
| private static final double | DEFAULT_TOO_SMALL
Default bound to determine effective singularity in LU decomposition. |
| private boolean | even
Parity of the permutation associated with the LU decomposition. |
| private final double[][] | lu
Entries of LU decomposition. |
| private final int[] | pivot
Pivot permutation associated with LU decomposition. |
| private boolean | singular
Singularity indicator. |
| Access | Constructor and Description |
|---|---|
| public | LUDecomposition(RealMatrix
Matrix to decompose. matrix)Calculates the LU-decomposition of the given matrix. |
| public | LUDecomposition(RealMatrix
The matrix to decompose. matrix, double threshold (based on partial row norm)
under which a matrix is considered singular singularityThreshold)Calculates the LU-decomposition of the given matrix. |
| Modifier and Type | Method and Description |
|---|---|
| public double | |
| public RealMatrix | Returns: the L matrix (or null if decomposed matrix is singular)Returns the matrix L of the decomposition. |
| public RealMatrix | Returns: the P rows permutation matrix (or null if decomposed matrix is singular)Returns the P rows permutation matrix. |
| public int[] | |
| public DecompositionSolver | |
| public RealMatrix | Returns: the U matrix (or null if decomposed matrix is singular)Returns the matrix U of the decomposition. |
| cachedL | back to summary |
|---|---|
| private RealMatrix cachedL Cached value of L. | |
| cachedP | back to summary |
|---|---|
| private RealMatrix cachedP Cached value of P. | |
| cachedU | back to summary |
|---|---|
| private RealMatrix cachedU Cached value of U. | |
| DEFAULT_TOO_SMALL | back to summary |
|---|---|
| private static final double DEFAULT_TOO_SMALL Default bound to determine effective singularity in LU decomposition. | |
| even | back to summary |
|---|---|
| private boolean even Parity of the permutation associated with the LU decomposition. | |
| lu | back to summary |
|---|---|
| private final double[][] lu Entries of LU decomposition. | |
| pivot | back to summary |
|---|---|
| private final int[] pivot Pivot permutation associated with LU decomposition. | |
| singular | back to summary |
|---|---|
| private boolean singular Singularity indicator. | |
| LUDecomposition | back to summary |
|---|---|
| public LUDecomposition(RealMatrix matrix) Calculates the LU-decomposition of the given matrix. This constructor uses 1e-11 as default value for the singularity threshold.
| |
| LUDecomposition | back to summary |
|---|---|
| public LUDecomposition(RealMatrix matrix, double singularityThreshold) Calculates the LU-decomposition of the given matrix.
| |
| getDeterminant | back to summary |
|---|---|
| public double getDeterminant() Return the determinant of the matrix
| |
| getL | back to summary |
|---|---|
| public RealMatrix getL() Returns the matrix L of the decomposition. L is a lower-triangular matrix
| |
| getP | back to summary |
|---|---|
| public RealMatrix getP() Returns the P rows permutation matrix. 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
| |
| getPivot | back to summary |
|---|---|
| public int[] getPivot() Returns the pivot permutation vector.
| |
| getSolver | back to summary |
|---|---|
| public DecompositionSolver getSolver() Get a solver for finding the A × X = B solution in exact linear sense.
| |
| getU | back to summary |
|---|---|
| public RealMatrix getU() Returns the matrix U of the decomposition. U is an upper-triangular matrix
| |
| Modifier and Type | Field and Description |
|---|---|
| private final double[][] | lu
Entries of LU decomposition. |
| private final int[] | pivot
Pivot permutation associated with LU decomposition. |
| private final boolean | singular
Singularity indicator. |
| Access | Constructor and Description |
|---|---|
| private | Solver(final double[][]
entries of LU decomposition lu, final int[] pivot permutation associated with LU decomposition pivot, final boolean singularity indicator singular)Build a solver from decomposed matrix. |
| Modifier and Type | Method and Description |
|---|---|
| public RealMatrix | Returns: the inverse matrix.Implements org. Get the inverse of the decomposed matrix. |
| public boolean | isNonSingular()
Implements org. Check if the decomposed matrix is non-singular. |
| public RealVector | solve(RealVector
right-hand side of the equation A × X = B b)Implements org. Solve the linear equation A × X = B for matrices A. |
| public RealMatrix | solve(RealMatrix
right-hand side of the equation A × X = B b)Implements org. Solve the linear equation A × X = B for matrices A. |
| lu | back to summary |
|---|---|
| private final double[][] lu Entries of LU decomposition. | |
| pivot | back to summary |
|---|---|
| private final int[] pivot Pivot permutation associated with LU decomposition. | |
| singular | back to summary |
|---|---|
| private final boolean singular Singularity indicator. | |
| Solver | back to summary |
|---|---|
| private Solver(final double[][] lu, final int[] pivot, final boolean singular) Build a solver from decomposed matrix.
| |
| getInverse | back to summary |
|---|---|
| public RealMatrix getInverse() Implements org. Get the inverse of the decomposed matrix.
| |
| isNonSingular | back to summary |
|---|---|
| public boolean isNonSingular() Implements org. Doc from org. Check if the decomposed matrix is non-singular.
| |
| solve | back to summary |
|---|---|
| public RealVector solve(RealVector b) Implements org. Doc from org. Solve the linear equation A × X = B for matrices A. The A matrix is implicit, it is provided by the underlying decomposition algorithm.
| |
| solve | back to summary |
|---|---|
| public RealMatrix solve(RealMatrix b) Implements org. Doc from org. Solve the linear equation A × X = B for matrices A. The A matrix is implicit, it is provided by the underlying decomposition algorithm.
| |