smile.math.matrix
Class LU
- java.lang.Object
-
- smile.math.matrix.LU
-
public class LU extends java.lang.ObjectFor 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 decomposition with pivoting always exists, even if the matrix is singular. The primary use of the LU decomposition is in the solution of square systems of simultaneous linear equations if it is not singular.
This decomposition can also be used to calculate the determinant.
-
-
Constructor Summary
Constructors Constructor and Description LU(DenseMatrix lu, int[] piv, boolean singular)Constructor.LU(DenseMatrix lu, int[] piv, int pivsign, boolean singular)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubledet()Returns the matrix determinantDenseMatrixinverse()Returns the matrix inverse.booleanisSingular()Returns true if the matrix is singular or false otherwise.voidsolve(DenseMatrix B)Solve A * X = B.voidsolve(double[] b)Solve A * x = b.
-
-
-
Constructor Detail
-
LU
public LU(DenseMatrix lu, int[] piv, int pivsign, boolean singular)
Constructor.- Parameters:
lu- LU decomposition matrixpiv- pivot vectorpivsign- pivot sign. +1 if even number of row interchanges, -1 if odd number of row interchanges.singular- True if the matrix is singular
-
LU
public LU(DenseMatrix lu, int[] piv, boolean singular)
Constructor.- Parameters:
lu- LU decomposition matrixpiv- pivot vectorsingular- True if the matrix is singular
-
-
Method Detail
-
isSingular
public boolean isSingular()
Returns true if the matrix is singular or false otherwise.
-
det
public double det()
Returns the matrix determinant
-
inverse
public DenseMatrix inverse()
Returns the matrix inverse. For pseudo inverse, use QRDecomposition.
-
solve
public void solve(double[] b)
Solve A * x = b.- Parameters:
b- right hand side of linear system. On output, b will be overwritten with the solution matrix.- Throws:
java.lang.RuntimeException- if matrix is singular.
-
solve
public void solve(DenseMatrix B)
Solve A * X = B. B will be overwritten with the solution matrix on output.- Parameters:
B- right hand side of linear system. On output, B will be overwritten with the solution matrix.- Throws:
java.lang.RuntimeException- if matrix is singular.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG