public class LUDecompositionImpl extends java.lang.Object implements LUDecomposition
The LUP-decomposition of a matrix A consists of three matrices L, U and P that satisfy: PA = LU, L is lower triangular, and 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.
Modifier and Type | Class and Description |
---|---|
private static class |
LUDecompositionImpl.Solver
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 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 double[][] |
lu
Entries of LU decomposition.
|
private int[] |
pivot
Pivot permutation associated with LU decomposition
|
private boolean |
singular
Singularity indicator.
|
Constructor and Description |
---|
LUDecompositionImpl(RealMatrix matrix)
Calculates the LU-decomposition of the given matrix.
|
LUDecompositionImpl(RealMatrix matrix,
double singularityThreshold)
Calculates the LU-decomposition of the given matrix.
|
Modifier and Type | Method and Description |
---|---|
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()
Get a solver for finding the A × X = B solution in exact linear sense.
|
RealMatrix |
getU()
Returns the matrix U of the decomposition.
|
private static final double DEFAULT_TOO_SMALL
private double[][] lu
private int[] pivot
private boolean even
private boolean singular
private RealMatrix cachedL
private RealMatrix cachedU
private RealMatrix cachedP
public LUDecompositionImpl(RealMatrix matrix) throws InvalidMatrixException
matrix
- The matrix to decompose.InvalidMatrixException
- if matrix is not squarepublic LUDecompositionImpl(RealMatrix matrix, double singularityThreshold) throws NonSquareMatrixException
matrix
- The matrix to decompose.singularityThreshold
- threshold (based on partial row norm)
under which a matrix is considered singularNonSquareMatrixException
- if matrix is not squarepublic RealMatrix getL()
L is an lower-triangular matrix
getL
in interface LUDecomposition
public RealMatrix getU()
U is an upper-triangular matrix
getU
in interface LUDecomposition
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
.
getP
in interface LUDecomposition
LUDecomposition.getPivot()
public int[] getPivot()
getPivot
in interface LUDecomposition
LUDecomposition.getP()
public double getDeterminant()
getDeterminant
in interface LUDecomposition
public DecompositionSolver getSolver()
getSolver
in interface LUDecomposition
Copyright (c) 2003-2014 Apache Software Foundation