nr
Class LUDecomposition

java.lang.Object
  extended by nr.LUDecomposition
All Implemented Interfaces:
MatDecomposition

public class LUDecomposition
extends java.lang.Object
implements MatDecomposition

LU Decomposition. Copied from the jama package from the NIST, but using nr.Mat and limited to square matrices

For an n-by-n matrix A, the LU decomposition is an n-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length n so that A(piv,:) = L*U.

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. Since this was developed by the US government, it is in the public domain.


Constructor Summary
LUDecomposition(Mat A)
          LU Decomposition
 
Method Summary
 double determinant()
          Returns the determinant
 double[] getDoublePivot()
          Returns the pivot permutation vector as a one-dimensional double array
 Mat getL()
          Returns the lower triangular factor
 int[] getPivot()
          Returns the pivot permutation vector
 Mat getU()
          Returns the upper triangular factor
 Mat inverse()
          find the inverse by solving for each column of the identity matrix.
 boolean isNonsingular()
          Is the matrix nonsingular?
 Vec solve(Vec B)
          Solve A*X = B
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LUDecomposition

public LUDecomposition(Mat A)
LU Decomposition

Parameters:
A - A square matrix
Method Detail

isNonsingular

public boolean isNonsingular()
Is the matrix nonsingular?

Returns:
true if U, and hence A, is nonsingular.

getL

public Mat getL()
Returns the lower triangular factor

Returns:
L

getU

public Mat getU()
Returns the upper triangular factor

Returns:
U

getPivot

public int[] getPivot()
Returns the pivot permutation vector

Returns:
pivot array

getDoublePivot

public double[] getDoublePivot()
Returns the pivot permutation vector as a one-dimensional double array

Returns:
(double) pivot array

determinant

public double determinant()
Returns the determinant

Returns:
det(A)

solve

public Vec solve(Vec B)
          throws DidNotConvergeException
Solve A*X = B

Specified by:
solve in interface MatDecomposition
Parameters:
B - a Vec
Returns:
X so that L*U*X = B(with pivoting)
Throws:
DidNotConvergeException - if B is singular.

inverse

public Mat inverse()
find the inverse by solving for each column of the identity matrix.

Specified by:
inverse in interface MatDecomposition