Record Class LU
java.lang.Object
java.lang.Record
smile.tensor.LU
- Record Components:
lu
- the LU decomposition matrix.ipiv
- the pivot vector.info
- the information code. Ifinfo = 0
, the LU decomposition was successful. Ifinfo = i > 0
, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.info > 0
if the matrix is singular.
- All Implemented Interfaces:
Serializable
The 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 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. The decomposition can also be used to calculate the determinant.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLU
(DenseMatrix lu, int[] ipiv, int info) Creates an instance of aLU
record class. -
Method Summary
Modifier and TypeMethodDescriptiondouble
det()
Returns the matrix determinant.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
info()
Returns the value of theinfo
record component.inverse()
Returns the inverse of matrix.int[]
ipiv()
Returns the value of theipiv
record component.boolean
Returns true if the matrix is singular.lu()
Returns the value of thelu
record component.solve
(double[] b) Solve A * x = b.solve
(float[] b) Solve A * x = b.void
solve
(DenseMatrix B) Solve A * X = B.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
isSingular
public boolean isSingular()Returns true if the matrix is singular.- Returns:
- true if the matrix is singular.
-
det
public double det()Returns the matrix determinant.- Returns:
- the matrix determinant.
-
inverse
Returns the inverse of matrix. For pseudo inverse, use QRDecomposition.- Returns:
- the inverse of matrix.
-
solve
Solve A * x = b.- Parameters:
b
- the right hand side of linear systems.- Returns:
- the solution vector.
- Throws:
RuntimeException
- when the matrix is singular.
-
solve
Solve A * x = b.- Parameters:
b
- the right hand side of linear systems.- Returns:
- the solution vector.
- Throws:
RuntimeException
- when the matrix is singular.
-
solve
Solve A * X = B. B will be overwritten with the solution matrix on output.- Parameters:
B
- the right hand side of linear system. On output, B will be overwritten with the solution matrix.- Throws:
RuntimeException
- when the matrix is singular.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with thecompare
method from their corresponding wrapper classes. -
lu
-
ipiv
-
info
-