Class SymmHess
java.lang.Object
org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition<Matrix,double[]>
org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
org.flag4j.linalg.decompositions.hess.RealHess
org.flag4j.linalg.decompositions.hess.SymmHess
- All Implemented Interfaces:
Decomposition<Matrix>
Computes the Hessenburg decomposition of a real dense symmetric matrix. That is, for a square, symmetric matrix
A
, computes the decomposition A=QHQ
T where Q
is an orthogonal matrix and
H
is a symmetric matrix in tri-diagonal form (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 is nearly diagonal except for possibly the first sub/super-diagonal.
Specifically, if H
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 x
may hold a different value (provided
the
matrix is symmetric):
[[ x x 0 0 0 ] [ x x x 0 0 ] [ 0 x x x 0 ] [ 0 0 x x x ] [ 0 0 0 x x ]]
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Flag 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, shift
Fields inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
applyUpdate, householderVector, minAxisSize, numCols, numRows, qFactors, storeReflectors, subDiagonal, transformData, transformMatrix, workArray
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
copyUpperTri
(Matrix src) Copies the upper triangular portion of a matrix to the working matrixUnitaryDecomposition.transformMatrix
.Applies decomposition to the source matrix.protected double
findMaxAndInit
(int j) Finds the maximum value inUnitaryDecomposition.transformMatrix
at columnj
at or below thej
th row.getH()
Gets the Hessenberg matrix from the decomposition.protected void
Performs basic setup for the decomposition.protected void
updateData
(int j) Updates theUnitaryDecomposition.transformMatrix
matrix using the computed Householder vector fromRealUnitaryDecomposition.computeHouseholder(int)
.Methods inherited from class org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
computeHouseholder, computePhasedNorm, getQ, getUpper, initWorkArrays
Methods inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
decomposeBase
-
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 orthogonalQ
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 orthogonalQ
matrix from the Hessenberg decomposition should be explicitly computed. If true, then theQ
matrix will be computed explicitly.
-
SymmHess
public SymmHess(boolean computeQ, boolean enforceSymmetric) Constructs a Hessenberg decomposer for symmetric matrices.- Parameters:
computeQ
- Flag indicating if the orthogonalQ
matrix from the Hessenberg decomposition should be explicitly computed. If true, then theQ
matrix will be computed explicitly.enforceSymmetric
- Flag indicating if an explicit check should be made to ensure any matrix passed todecompose(Matrix)
is truly symmetric. If true, an exception will be thrown if the matrix is not symmetric. If false, 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.
-
-
Method Details
-
decompose
Applies decomposition to the source matrix.- Specified by:
decompose
in interfaceDecomposition<Matrix>
- Overrides:
decompose
in classRealHess
- Parameters:
src
- The source matrix to decompose. (Assumed to be a symmetric matrix).- Returns:
- A reference to this decomposer.
-
getH
-
findMaxAndInit
protected double findMaxAndInit(int j) Finds the maximum value inUnitaryDecomposition.transformMatrix
at columnj
at or below thej
th row. This method also initializes the firstnumRows-j
entries of the storage arrayUnitaryDecomposition.householderVector
to the entries of this column.- Overrides:
findMaxAndInit
in classRealUnitaryDecomposition
- Parameters:
j
- Index of column (and starting row) to compute max of.- Returns:
- The maximum value in
UnitaryDecomposition.transformMatrix
at columnj
at or below thej
th row.
-
setUp
Performs basic setup for the decomposition.- Overrides:
setUp
in classUnitaryDecomposition<Matrix,
double[]> - Parameters:
src
- The matrix to be decomposed.- Throws:
LinearAlgebraException
- If the matrix is not symmetric andenforceSymmetric
is true or if the matrix is not square regardless of the value ofenforceSymmetric
.
-
copyUpperTri
Copies the upper triangular portion of a matrix to the working matrixUnitaryDecomposition.transformMatrix
.- Parameters:
src
- The source matrix to decompose of.
-
updateData
protected void updateData(int j) Updates theUnitaryDecomposition.transformMatrix
matrix using the computed Householder vector fromRealUnitaryDecomposition.computeHouseholder(int)
.- Overrides:
updateData
in classRealUnitaryDecomposition
- Parameters:
j
- Index of sub-matrix for which the Householder reflector was computed for.
-