public class LU
extends java.lang.Object
The LU decomposition with pivoting always exists, even if the matrix is singular. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations if it is not singular.
This decomposition can also be used to calculate the determinant.
| Modifier and Type | Field and Description |
|---|---|
protected DenseMatrix |
lu
Array for internal storage of decomposition.
|
protected int[] |
piv
Internal storage of pivot vector.
|
protected int |
pivsign
pivot sign.
|
protected boolean |
singular
True if the matrix is singular.
|
| Constructor and Description |
|---|
LU(DenseMatrix lu,
int[] piv,
boolean singular)
Constructor.
|
LU(DenseMatrix lu,
int[] piv,
int pivsign,
boolean singular)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
det()
Returns the matrix determinant
|
DenseMatrix |
inverse()
Returns the matrix inverse.
|
boolean |
isSingular()
Returns true if the matrix is singular or false otherwise.
|
void |
solve(DenseMatrix B)
Solve A * X = B.
|
void |
solve(double[] b)
Solve A * x = b.
|
protected DenseMatrix lu
protected int pivsign
protected int[] piv
protected boolean singular
public LU(DenseMatrix lu, int[] piv, int pivsign, boolean singular)
lu - LU decomposition matrixpiv - pivot vectorpivsign - pivot sign. +1 if even number of row interchanges, -1 if odd number of row interchanges.singular - True if the matrix is singularpublic LU(DenseMatrix lu, int[] piv, boolean singular)
lu - LU decomposition matrixpiv - pivot vectorsingular - True if the matrix is singularpublic boolean isSingular()
public double det()
public DenseMatrix inverse()
public void solve(double[] b)
b - right hand side of linear system.
On output, b will be overwritten with the solution matrix.java.lang.RuntimeException - if matrix is singular.public void solve(DenseMatrix B)
B - right hand side of linear system.
On output, B will be overwritten with the solution matrix.java.lang.RuntimeException - if matrix is singular.