Package cern.colt.matrix.linalg
Class LUDecomposition
java.lang.Object
cern.colt.matrix.linalg.LUDecomposition
- All Implemented Interfaces:
Serializable
For an m x n matrix A with m >= n, the LU decomposition is an m x n
unit lower triangular matrix L, an n x n upper triangular matrix U,
and a permutation vector piv of length m so that A(piv,:) = L*U;
If m invalid input: '<' n, then L is m x m and U is m x n.
The LU decomposition 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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LUDecompositionQuick
(package private) static final long
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs and returns a new LU Decomposition object; The decomposed matrices can be retrieved via instance methods of the returned decomposition object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
det()
Returns the determinant, det(A).private double[]
Returns pivot permutation vector as a one-dimensional double arraygetL()
Returns the lower triangular factor, L.int[]
getPivot()
Returns a copy of the pivot permutation vector.getU()
Returns the upper triangular factor, U.boolean
Returns whether the matrix is nonsingular (has an inverse).Solves A*X = B.toString()
Returns a String with (propertyName, propertyValue) pairs.
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
quick
-
-
Constructor Details
-
LUDecomposition
Constructs and returns a new LU Decomposition object; The decomposed matrices can be retrieved via instance methods of the returned decomposition object.- Parameters:
A
- Rectangular matrix
-
-
Method Details
-
det
public double det()Returns the determinant, det(A).- Throws:
IllegalArgumentException
- Matrix must be square
-
getDoublePivot
private double[] getDoublePivot()Returns pivot permutation vector as a one-dimensional double array- Returns:
- (double) piv
-
getL
Returns the lower triangular factor, L.- Returns:
- L
-
getPivot
public int[] getPivot()Returns a copy of the pivot permutation vector.- Returns:
- piv
-
getU
Returns the upper triangular factor, U.- Returns:
- U
-
isNonsingular
public boolean isNonsingular()Returns whether the matrix is nonsingular (has an inverse).- Returns:
- true if U, and hence A, is nonsingular; false otherwise.
-
solve
Solves A*X = B.- Parameters:
B
- A matrix with as many rows as A and any number of columns.- Returns:
- X so that L*U*X = B(piv,:).
- Throws:
IllegalArgumentException
- if B.rows() != A.rows().IllegalArgumentException
- if A is singular, that is, if !this.isNonsingular().IllegalArgumentException
- if A.rows() invalid input: '<' A.columns().
-
toString
Returns a String with (propertyName, propertyValue) pairs. Useful for debugging or to quickly get the rough picture. For example,rank : 3 trace : 0
-