public class LUDecomposition
extends java.lang.Object
Providing a separate class for the LU decomposition allows an application to perform such decompositions repeatedly without having to reallocate temporary storage space.
Constructor and Description |
---|
LUDecomposition()
Creates an uninitialized LUDecomposition.
|
LUDecomposition(int n)
Creates an uninitialized LUDecomposition with enough capacity to handle
matrices of size
n . |
LUDecomposition(Matrix M)
Creates an LUDecomposition for the Matrix specified by M.
|
Modifier and Type | Method and Description |
---|---|
double |
conditionEstimate(Matrix M)
Estimates the condition number of the original matrix M associated with
this decomposition.
|
double |
determinant()
Compute the determinant of the original matrix M associated with this
decomposition.
|
void |
factor(Matrix M)
Peforms an LU decomposition on the Matrix M.
|
void |
get(MatrixNd L,
MatrixNd U,
int[] rperm)
Gets the matrices associated with the LU decomposition.
|
boolean |
inverse(DenseMatrix R)
Computes the inverse of the original matrix M associated with this
decomposition, and places the result in R.
|
boolean |
solve(DenseMatrix X,
Matrix B)
Solves the linear equation
M X = B where M is the original matrix associated with this decomposition, and X and B are matrices. |
boolean |
solve(Vector x,
Vector b)
Solves the linear equation
M x = b where M is the original matrix associated with this decomposition, and x and b are vectors. |
public LUDecomposition()
public LUDecomposition(int n)
n
. This capacity will later be increased
on demand.n
- initial maximum matrix sizepublic LUDecomposition(Matrix M) throws ImproperSizeException
M
- matrix to perform the LU decomposition onImproperSizeException
- if M is not squarepublic void factor(Matrix M) throws ImproperSizeException
M
- matrix to perform the LU decomposition onImproperSizeException
- if M is not squarepublic void get(MatrixNd L, MatrixNd U, int[] rperm) throws ImproperStateException, ImproperSizeException
L
- unit lower triangular matrixU
- upper triangular matrixrperm
- indices of the row permuation matrix P, such that the i-th row of P M is
given by row perm[i]
of M.ImproperStateException
- if this LUDecomposition is uninitializedImproperSizeException
- if L or U are not of the proper dimension and cannot be resized, or if the
length of perm is less than the size of M.public boolean solve(Vector x, Vector b) throws ImproperStateException, ImproperSizeException
x
- unknown vector to solve forb
- constant vectorImproperStateException
- if this decomposition is uninitializedImproperSizeException
- if b does not have a size compatible with M, or if x does not have a size
compatible with M and cannot be resized.public boolean solve(DenseMatrix X, Matrix B) throws ImproperStateException, ImproperSizeException
X
- unknown matrix to solve forB
- constant matrixImproperStateException
- if this decomposition is uninitializedImproperSizeException
- if B has a different number of rows than M, or if X has a different number
of rows than M or a different number of columns than B and cannot be
resized.public double conditionEstimate(Matrix M) throws ImproperStateException, ImproperSizeException
M
- original matrixImproperStateException
- if this LUDecomposition is uninitializedImproperSizeException
- if the size of M does not match the size of the current LU decompositionpublic double determinant() throws ImproperStateException
ImproperStateException
- if this decomposition is uninitializedpublic boolean inverse(DenseMatrix R) throws ImproperStateException
R
- matrix in which the inverse is storedImproperStateException
- if this decomposition is uninitializedImproperSizeException
- if R does not have the same size as M and cannot be resized.