public class LUDecomposition
extends java.lang.Object
implements java.io.Serializable
For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(piv,:) = L*U. If m < n, then L is m-by-m and U is m-by-n.
The LU decompostion with pivoting always exists, even if the matrix is singular, so the constructor will never fail. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations. This will fail if isNonsingular() returns false.
| Constructor and Description |
|---|
LUDecomposition(double[][] matrix)
Initializes a new instance of the LUDecomposition class.
|
| Modifier and Type | Method and Description |
|---|---|
double |
determinant()
Calculate the determinant.
|
double[] |
getDoublePivot()
Get the pivot permutation vector as double type.
|
double[][] |
getL()
Get the Lower triangular factor.
|
int[] |
getPivot()
Get the pivot permutation vector.
|
double[][] |
getU()
Get the Upper triangular factor.
|
double[][] |
inverse()
Matrix inverse or pseudoinverse.
|
boolean |
isNonsingular()
Check if the matrix is non singular.
|
double[][] |
solve(double[][] B)
Solve A*X = B
|
public LUDecomposition(double[][] matrix)
matrix - Matrix.public boolean isNonsingular()
public double[][] inverse()
public double[][] getL()
public double[][] getU()
public int[] getPivot()
public double[] getDoublePivot()
public double determinant()
public double[][] solve(double[][] B)
B - A Matrix with as many rows as A and any number of columns.java.lang.IllegalArgumentException - Matrix row dimensions must agree.java.lang.RuntimeException - Matrix is singular.