SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.factorization.triangle
Class Doolittle

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.factorization.triangle.Doolittle
All Implemented Interfaces:
LUDecomposition

public class Doolittle
extends java.lang.Object
implements LUDecomposition

This class implements the Doolittle algorithm with column/partial pivoting for the LU decomposition of a square matrix. It iteratively fills the first row, then first column, then second row, second column, etc. Before each iteration, it swaps the rows so that the biggest entry in the column is on the main diagonal. If this biggest entry is 0, the Doolittle construction fails and throws a runtime exception.

On success, we have

P %*% A == L %*% U
where A is an n x n matrix, P is an n x n pivoting matrix, L is an n x n lower triangular matrix, U is an n x n upper triangular matrix.

That is,

P.multiply(A) == L.multiply(U)

Singular matrix can have valid LU decomposition.

Note that not every non-singular matrix can be factored as A = L %*% U. E.g., |1, 0, 0| |0, 0, 2| |0, 1, -1|

On the other hand, the LU decomposition with pivoting always exists, even if the matrix is singular.


Field Summary
 int dim
          the dimension of the square matrix A
 double epsilon
          a precision parameter: when a number |x| ≤ ε, it is considered 0
 boolean usePivoting
          true if partial pivoting is wanted, e.g., for numerical stability
 
Constructor Summary
Doolittle(Matrix A)
          Construct an LU decomposition using the Doolittle algorithm.
Doolittle(Matrix A, boolean usePivoting, double epsilon)
          Construct an LU decomposition using the Doolittle algorithm.
 
Method Summary
 LowerTriangularMatrix L()
          Get a copy of the lower triangular matrix L as in P %*% A == L %*% U
 PermutationMatrix P()
          Get a copy of the permutation matrix P as in P %*% A == L %*% U
 UpperTriangularMatrix U()
          Get a copy of the upper triangular matrix U as in P %*% A == L %*% U
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dim

public final int dim
the dimension of the square matrix A


usePivoting

public final boolean usePivoting
true if partial pivoting is wanted, e.g., for numerical stability


epsilon

public final double epsilon
a precision parameter: when a number |x| ≤ ε, it is considered 0

Constructor Detail

Doolittle

public Doolittle(Matrix A,
                 boolean usePivoting,
                 double epsilon)
Construct an LU decomposition using the Doolittle algorithm.

Parameters:
A - a square matrix
usePivoting - true if partial pivoting is wanted, e.g., for numerical stability
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
Throws:
java.lang.IllegalArgumentException - if A is not square

Doolittle

public Doolittle(Matrix A)
Construct an LU decomposition using the Doolittle algorithm.

Parameters:
A - a square matrix to which Doolittle is applied
Throws:
java.lang.IllegalArgumentException - if A is not square
Method Detail

L

public LowerTriangularMatrix L()
Description copied from interface: LUDecomposition
Get a copy of the lower triangular matrix L as in
P %*% A == L %*% U

Specified by:
L in interface LUDecomposition
Returns:
a copy of L

U

public UpperTriangularMatrix U()
Description copied from interface: LUDecomposition
Get a copy of the upper triangular matrix U as in
P %*% A == L %*% U

Specified by:
U in interface LUDecomposition
Returns:
a copy of U

P

public PermutationMatrix P()
Description copied from interface: LUDecomposition
Get a copy of the permutation matrix P as in
P %*% A == L %*% U

Specified by:
P in interface LUDecomposition
Returns:
a copy of P

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.