edu.mines.jtk.lapack
Class DMatrixLud

java.lang.Object
  extended by edu.mines.jtk.lapack.DMatrixLud

public class DMatrixLud
extends java.lang.Object

LU decomposition of a matrix A. For an m-by-n matrix A, the LU decomposition is A = P*L*U or A(p,:) = L*U, where P is an m-by-m row permutation matrix, p is a corresponding array of m row permutation indices, L is an m-by-min(m,n) lower triangular or trapezoidal matrix with unit diagonal elements, and U is a min(m,n)-by-n upper triangular or trapezoidal matrix.

The LU decomposition with pivoting never fails, even if the matrix A is singular. However, the primary use of LU decomposition is in the solution of square systems of linear equations, which will fail if A is singular (or not square).

Version:
2005.12.12
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
DMatrixLud(DMatrix a)
          Constructs an LU decomposition of the specified matrix A.
 
Method Summary
 double det()
          Returns the determinant of the square matrix A.
 DMatrix getL()
          Gets the lower triangular (or lower trapezoidal) factor L.
 DMatrix getP()
          Gets the row permutation matrix P.
 int[] getPivotIndices()
          Gets the array of row permutation (pivot) indices p.
 DMatrix getU()
          Gets the upper triangular (or upper trapezoidal) factor U.
 boolean isSingular()
          Determines whether the matrix A is singular.
 DMatrix solve(DMatrix b)
          Returns the solution X of the linear system A*X = B.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DMatrixLud

public DMatrixLud(DMatrix a)
Constructs an LU decomposition of the specified matrix A.

Parameters:
a - the matrix.
Method Detail

isSingular

public boolean isSingular()
Determines whether the matrix A is singular. If singular, then this decomposition cannot be used to solve systems of linear equations.

Returns:
true, if singular; false, otherwise.

getL

public DMatrix getL()
Gets the lower triangular (or lower trapezoidal) factor L. The matrix L has dimensions m-by-min(m,n) and unit diagonal elements.

Returns:
the factor L.

getU

public DMatrix getU()
Gets the upper triangular (or upper trapezoidal) factor U. The matrix U has dimensions min(m,n)-by-n.

Returns:
the factor L.

getP

public DMatrix getP()
Gets the row permutation matrix P. The matrix P has dimensions m-by-m.

Returns:
the permutation matrix P.

getPivotIndices

public int[] getPivotIndices()
Gets the array of row permutation (pivot) indices p. In this decomposition of the m-by-n matrix A, row i was interchanged with row p[i], for i = 0, 1, 2, ..., m-1.

Returns:
the pivot indices p.

det

public double det()
Returns the determinant of the square matrix A. The determinant exists only for square matrices A.

Returns:
the determinant.

solve

public DMatrix solve(DMatrix b)
Returns the solution X of the linear system A*X = B. The matrix A must be square and non singular. Also, the matrices A and B must have the same number of rows.

Parameters:
b - the right-hand-side matrix B.
Returns:
the solution matrix X.