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.
Modifier and Type | Field and Description |
---|---|
private double[][] |
LU
Array for internal storage of decomposition.
|
private int |
m
Row and column dimensions, and pivot sign.
|
private int |
n
Row and column dimensions, and pivot sign.
|
private int[] |
piv
Internal storage of pivot vector.
|
private int |
pivsign
Row and column dimensions, and pivot sign.
|
private static long |
serialVersionUID
Serial version
|
Constructor and Description |
---|
LUDecomposition(double[][] LU)
LU Decomposition
|
LUDecomposition(double[][] LU,
int m,
int n)
LU Decomposition
|
Modifier and Type | Method and Description |
---|---|
double |
det()
Determinant
|
double[][] |
getL()
Return lower triangular factor
|
int[] |
getPivot()
Return pivot permutation vector
|
double[][] |
getU()
Return upper triangular factor
|
double[][] |
inverse()
Find the inverse matrix.
|
boolean |
isNonsingular()
Is the matrix nonsingular?
|
double[] |
solve(double[] b)
Solve A*X = b
|
double[][] |
solve(double[][] B)
Solve A*X = B
|
double[] |
solveInplace(double[] b)
Solve A*X = b
|
private double[][] |
solveInplace(double[][] B)
Solve A*X = B
|
private static final long serialVersionUID
private double[][] LU
private int m
private int n
private int pivsign
private int[] piv
public LUDecomposition(double[][] LU)
LU
- Rectangular matrixpublic LUDecomposition(double[][] LU, int m, int n)
LU
- Rectangular matrixm
- row dimensionalityn
- column dimensionalitypublic boolean isNonsingular()
public double[][] getL()
public double[][] getU()
public int[] getPivot()
public double det()
java.lang.IllegalArgumentException
- Matrix must be squarepublic 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.ArithmeticException
- Matrix is singular.private double[][] solveInplace(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.ArithmeticException
- Matrix is singular.public double[] solve(double[] b)
b
- A column vector with as many rows as Ajava.lang.IllegalArgumentException
- Matrix row dimensions must agree.java.lang.ArithmeticException
- Matrix is singular.public double[] solveInplace(double[] b)
b
- A vectorjava.lang.IllegalArgumentException
- Matrix row dimensions must agree.java.lang.ArithmeticException
- Matrix is singular.public double[][] inverse()
java.lang.ArithmeticException
- Matrix is rank deficient.Copyright © 2019 ELKI Development Team. License information.