package math.matrix; import java.io.Serializable; /** * LU Decomposition. *
* For an m-by-n matrix A with m ≥ n, the LU decomposition is an m-by-n * unit lower triangular matrix L, an n-by-n upper triangular matrix U, * and a permutation vector piv of length m so that A(piv,:) = L*U. * If m < n, then L is m-by-m and U is m-by-n. *
* 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.
*/
public class LUDecomposition implements Serializable {
/**
* UID
*/
private static final long serialVersionUID = -3852210156107961377L;
/**
* Array for internal storage of decomposition.
* @serial internal array storage
*/
private double[][] LU;
/**
* @serial row dimension
*/
private int m;
/**
* @serial column dimension
*/
private int n;
/**
* @serial pivot sign
*/
private int pivsign;
/**
* Internal storage of pivot vector.
* @serial pivot vector.
*/
private int[] piv;
/**
* LU Decomposition
* Structure to access L, U and piv.
* @param A Rectangular matrix
*/
public LUDecomposition(Matrix A){
int i, j, k;
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
LU = A.getCopy();
m = A.getM();
n = A.getN();
piv = new int[m];
for(i=0; i
Structure to access L, U and piv.
@param A Rectangular matrix
@param linpackflag Use Gaussian elimination. Actual value ignored.
*/
public LUDecomposition(Matrix A, int linpackflag){
int i, j, k;
// Initialize.
LU = A.getCopy();
m = A.getM();
n = A.getN();
piv = new int[m];
for(i=0; i