Class Decomposition<T extends MatrixMixin<T,?,?,?>>
- Type Parameters:
T
- The type of matrix that this decomposition operates on.
An abstract base class representing a matrix decomposition.
This class provides a foundation for various matrix decompositions,
such as LU, QR, SVD, Schur, and Hessenburg decompositions. Implementing classes must define
the decomposition process by overriding the decompose(MatrixMixin)
method.
Usage:
A typical workflow using a decomposition class follows these steps:
- Instantiate a concrete implementation of a decomposition.
- Call
decompose(MatrixMixin)
to perform the decomposition and a specific matrix. - Retrieve decomposition results via additional getter methods provided by the subclass.
State Management:
The class maintains an internal state flag, hasDecomposed
, which tracks whether
a matrix decomposition has been performed. This ensures that methods depending on the
decomposition can verify its existence before proceeding. The ensureHasDecomposed()
method is provided to enforce this check. Below is a minimal example usage of ensureHasDecomposed()
for
a LU decomposition.
class RealLU extends Decomposition<Matrix> {
Matrix L;
Matrix U;
// Other fields and constructors...
@Override
public RealLU decompose(Matrix a) {
// LU implementation...
super.hasDecomposed = true;
return this;
}
public Matrix getL() {
super.ensureHasDecomposed();
return L;
}
public Matrix getU() {
super.ensureHasDecomposed();
return U;
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Flag indicating if this instance has computed a decomposition. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Decomposition
<T> Applies decomposition to the source matrix.protected void
Ensures that this instance has computed a decomposition.
-
Field Details
-
hasDecomposed
protected boolean hasDecomposedFlag indicating if this instance has computed a decomposition.- If
true
then this instance has decomposed a matrix. - If
false
then this instance has not yet decomposed a matrix.
- If
-
-
Constructor Details
-
Decomposition
public Decomposition()
-
-
Method Details
-
decompose
Applies decomposition to the source matrix.- Parameters:
src
- The source matrix to decompose.- Returns:
- A reference to this decomposer.
-
ensureHasDecomposed
protected void ensureHasDecomposed()Ensures that this instance has computed a decomposition.
This is useful to ensure that a decomposition has been computed in a method that depends on the result of the decomposition.
- Throws:
IllegalStateException
- IfhasDecomposed == False
.
-