Class SymmHess
Computes the Hessenberg decomposition of a real dense symmetric matrix.
The Hessenberg decomposition decomposes a given symmetric matrix \( A \) into the product: \[ A = QHQ^{T} \] where \( Q \) is an orthogonal matrix and \( H \) is a symmetric tri-diagonal matrix (special case of Hessenburg form) which is similar to \( A \) (i.e. has the same eigenvalues)
A matrix \( H \) is in tri-diagonal form if it has all zeros below the first sub-diagonal and above the first super-diagonal.
For example, the following matrix is in symmetric tri-diagonal form where each '\( \times \)' may hold a different value (provided the matrix is symmetric): \[ \begin{bmatrix} \times & \times & 0 & 0 & 0 \\ \times & \times & \times & 0 & 0 \\ 0 & \times & \times & \times & 0 \\ 0 & 0 & \times & \times & \times \\ 0 & 0 & 0 & \times & \times \\ \end{bmatrix} \]
Efficiency Considerations:
- If the orthogonal matrix \( Q \) is not required, setting
computeQ = falsein the constructor may improve performance. - Support for in-place decomposition to reduce memory usage.
Usage:
The decomposition workflow typically follows these steps:- Instantiate an instance of
SymmHess. - Call
decompose(Matrix)to perform the factorization. - Retrieve the resulting matrices using
getH()andRealUnitaryDecomposition.getQ().
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag indicating if an explicit check should be made that the matrix to be decomposed is symmetric.Fields inherited from class org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
currentFactor, norm, shiftFields inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
applyUpdate, householderVector, iHigh, iLow, inPlace, minAxisSize, numCols, numRows, qFactors, storeReflectors, subDiagonal, transformData, transformMatrix, workArrayFields inherited from class org.flag4j.linalg.decompositions.Decomposition
hasDecomposed -
Constructor Summary
ConstructorsConstructorDescriptionSymmHess()Constructs a Hessenberg decomposer for symmetric matrices.SymmHess(boolean computeQ) Constructs a Hessenberg decomposer for symmetric matrices.SymmHess(boolean computeQ, boolean enforceSymmetric) Constructs a Hessenberg decomposer for symmetric matrices.SymmHess(boolean computeQ, boolean enforceSymmetric, boolean inPlace) Constructs a Hessenberg decomposer for symmetric matrices. -
Method Summary
Modifier and TypeMethodDescriptionApplies decomposition to the source matrix.protected doublefindMaxAndInit(int j) Finds the maximum value inUnitaryDecomposition.transformMatrixat columnjat or below thejth row.getH()Gets the Hessenberg matrix, \( H \), from the decomposition.protected voidPerforms basic setup for the decomposition.protected voidupdateData(int j) Updates theUnitaryDecomposition.transformMatrixmatrix using the computed Householder vector fromRealUnitaryDecomposition.computeHouseholder(int).Methods inherited from class org.flag4j.linalg.decompositions.hess.RealHess
decompose, getUpper, initQMethods inherited from class org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
computeHouseholder, computePhasedNorm, getQ, getUpper, initWorkArraysMethods inherited from class org.flag4j.linalg.decompositions.Decomposition
ensureHasDecomposed
-
Field Details
-
enforceSymmetric
protected boolean enforceSymmetricFlag indicating if an explicit check should be made that the matrix to be decomposed is symmetric.
-
-
Constructor Details
-
SymmHess
public SymmHess()Constructs a Hessenberg decomposer for symmetric matrices. By default, the Householder vectors used in the decomposition will be stored so that the full orthogonal \( Q \) matrix can be formed by callingRealUnitaryDecomposition.getQ(). -
SymmHess
public SymmHess(boolean computeQ) Constructs a Hessenberg decomposer for symmetric matrices.- Parameters:
computeQ- Flag indicating if the orthogonal \( Q \) matrix from the Hessenberg decomposition should be explicitly computed. iftrue, then the \( Q \) matrix will be computed explicitly. If \( Q \) is not needed, setting this tofalsemay yield an increase in performance.
-
SymmHess
public SymmHess(boolean computeQ, boolean enforceSymmetric) Constructs a Hessenberg decomposer for symmetric matrices.- Parameters:
computeQ- Flag indicating if the orthogonal \( Q \) matrix from the Hessenberg decomposition should be explicitly computed. iftrue, then the \( Q \) matrix will be computed explicitly. If \( Q \) is not needed, setting this tofalsemay yield an increase in performance.enforceSymmetric- Flag indicating if an explicit check should be made to ensure any matrix passed todecompose(Matrix)is truly symmetric. Iftrue, an exception will be thrown if the matrix is not symmetric. Iffalse, the decomposition will proceed under the assumption that the matrix is symmetric whether it actually is or not. If the matrix is not symmetric, then the values in the upper triangular portion of the matrix are taken to be the values.
-
SymmHess
public SymmHess(boolean computeQ, boolean enforceSymmetric, boolean inPlace) Constructs a Hessenberg decomposer for symmetric matrices.- Parameters:
computeQ- Flag indicating if the orthogonal \( Q \) matrix from the Hessenberg decomposition should be explicitly computed. iftrue, then the \( Q \) matrix will be computed explicitly. If \( Q \) is not needed, setting this tofalsemay yield an increase in performance.enforceSymmetric- Flag indicating if an explicit check should be made to ensure any matrix passed todecompose(Matrix)is truly symmetric. Iftrue, an exception will be thrown if the matrix is not symmetric. Iffalse, the decomposition will proceed under the assumption that the matrix is symmetric whether it actually is or not. If the matrix is not symmetric, then the values in the upper triangular portion of the matrix are taken to be the values.inPlace- Flag indicating if the decomposition should be done in-place.- If
true, then the decomposition will be done in place. - If
false, then the decomposition will be done out-of-place.
- If
-
-
Method Details
-
decompose
-
getH
-
findMaxAndInit
protected double findMaxAndInit(int j) Finds the maximum value inUnitaryDecomposition.transformMatrixat columnjat or below thejth row. This method also initializes the firstnumRows-jdata of the storage arrayUnitaryDecomposition.householderVectorto the data of this column.- Overrides:
findMaxAndInitin classRealUnitaryDecomposition- Parameters:
j- Index of column (and starting row) to compute max of.- Returns:
- The maximum value in
UnitaryDecomposition.transformMatrixat columnjat or below thejth row.
-
setUp
Performs basic setup for the decomposition.- Overrides:
setUpin classUnitaryDecomposition<Matrix,double[]> - Parameters:
src- The matrix to be decomposed.- Throws:
LinearAlgebraException- If the matrix is not symmetric andenforceSymmetricis true or if the matrix is not square regardless of the value ofenforceSymmetric.
-
updateData
protected void updateData(int j) Updates theUnitaryDecomposition.transformMatrixmatrix using the computed Householder vector fromRealUnitaryDecomposition.computeHouseholder(int).- Overrides:
updateDatain classRealUnitaryDecomposition- Parameters:
j- Index of sub-matrix for which the Householder reflector was computed for.
-