Class FieldLU<T extends Field<T>>
- Type Parameters:
T- The type of the field the elements of the matrix to decompose are members of.
Instances of this class can be used to compute the LU decomposition of a complex dense matrix.
The LU decomposition decomposes a matrix \( A \) into the product of a unit-lower triangular matrix \( L \) and an upper triangular matrix \( U \), such that: \[ A = LU \]
Pivoting Strategies:
Pivoting may be used to improve the stability of the decomposition. Pivoting involves swapping rows and/or columns within the matrix during decomposition.
This class supports three pivoting strategies via the LU.Pivoting enum:
LU.Pivoting.NONE: No pivoting is performed. This pivoting strategy is generally not recommended. \[ A = LU \]LU.Pivoting.PARTIAL: Only row pivoting is performed to improve numerical stability. Generally, this is the preferred pivoting strategy. The decomposition then becomes, \[ PA = LU \]
where \( P \) is a LU.Pivoting.FULL: Both row and column pivoting are performed to enhance numerical robustness. The decomposition then becomes, \[ PAQ = LU \] where \( P \) and \( Q \) arepermutation matricesrepresenting the row and column swaps respectively.Full pivoting may be useful for highly ill-conditioned matrices but, for practical purposes, partial pivoting is generally sufficient and more performant.
permutation matrix representing the row swaps.
Storage Format:
The computed LU decomposition is stored within a single matrixLU, where:
- The upper triangular part (including the diagonal) represents the non-zero values of \( U \).
- The strictly lower triangular part represents the non-zero, non-diagonal values of \( L \). Since \( L \) is unit-lower triangular, the diagonal is not stored as it is known to be all zeros.
Usage:
The decomposition workflow typically follows these steps:- Instantiate an instance of
FieldLU. - Call
LU.decompose(MatrixMixin)to perform the factorization. - Retrieve the resulting matrices using
getL(),getU(),LU.getP(), andLU.getQ().
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.flag4j.linalg.decompositions.lu.LU
LU.Pivoting -
Field Summary
Fields inherited from class org.flag4j.linalg.decompositions.lu.LU
colSwaps, inPlace, LU, numColSwaps, numRowSwaps, P, pivotFlag, Q, rowSwaps, ZERO_PIV_ERRFields inherited from class org.flag4j.linalg.decompositions.Decomposition
hasDecomposed -
Constructor Summary
ConstructorsModifierConstructorDescriptionFieldLU()Constructs a LU decomposer for dense field matrices.FieldLU(LU.Pivoting pivoting) Constructs a LU decomposer for dense field matrices.protectedFieldLU(LU.Pivoting pivoting, boolean inPlace) Constructs a LU decomposer for dense field matrices. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidComputes the LU decomposition using full/rook pivoting (i.e. row and column swapping).getL()Gets the unit lower triangular matrix of the decomposition.getU()Gets the upper triangular matrix of the decomposition.protected voidnoPivot()Computes the LU decomposition using no pivoting (i.e. rows and columns are not swapped).protected voidComputes the LU decomposition using partial pivoting (i.e. row swapping).Methods inherited from class org.flag4j.linalg.decompositions.lu.LU
decompose, getLU, getNumColSwaps, getNumRowSwaps, getP, getQ, initLU, swapCols, swapRowsMethods inherited from class org.flag4j.linalg.decompositions.Decomposition
ensureHasDecomposed
-
Constructor Details
-
FieldLU
public FieldLU()Constructs a LU decomposer for dense field matrices.
This decomposition will be performed out-of-place using partial pivoting.
-
FieldLU
Constructs a LU decomposer for dense field matrices.
This decomposition will be performed out-of-place.
- Parameters:
pivoting- Pivoting to use. If pivoting is 2, full pivoting will be used. If pivoting is 1, partial pivoting will be used. If pivoting is any other value, no pivoting will be used.
-
FieldLU
Constructs a LU decomposer for dense field matrices.- Parameters:
pivoting- Pivoting to use.inPlace- Flag indicating if the decomposition should be done in/out-of-place.- If
true, then the decomposition will be done in-place. - If
true, then the decomposition will be done out-of-place.
- If
-
-
Method Details
-
noPivot
-
partialPivot
protected void partialPivot()Computes the LU decomposition using partial pivoting (i.e. row swapping).- Specified by:
partialPivotin classLU<FieldMatrix<T extends Field<T>>>
-
fullPivot
-
getL
Gets the unit lower triangular matrix of the decomposition.- Specified by:
getLin classLU<FieldMatrix<T extends Field<T>>>- Returns:
- The lower triangular matrix of the decomposition.
- Throws:
IllegalStateException- If this method is called before.invalid reference
#decompose(FieldMatrix)
-
getU
Gets the upper triangular matrix of the decomposition.- Specified by:
getUin classLU<FieldMatrix<T extends Field<T>>>- Returns:
- The lower triangular matrix of the decomposition.
- Throws:
IllegalStateException- If this method is called before.invalid reference
#decompose(FieldMatrix)
-