Class ComplexUnitaryDecomposition
java.lang.Object
org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition<CMatrix,CNumber[]>
org.flag4j.linalg.decompositions.unitary.ComplexUnitaryDecomposition
- All Implemented Interfaces:
Decomposition<CMatrix>
- Direct Known Subclasses:
ComplexHess
,ComplexQR
This class is the base class for complex matrix decompositions which proceed by using unitary transformations
(specifically Householder reflectors) to bring a matrix into an upper triangular/Hessenburg matrix. Specifically, the
QR
and
Hessenburg decompositions.-
Field Summary
Modifier and TypeFieldDescriptionprivate CNumber
Scalar factor of the currently computed Householder reflector.protected CNumber
For storing the scaled, phase-adjusted norm.protected double
To store norms of columns inUnitaryDecomposition.transformMatrix
.private CNumber
Stores the shifted value of the first entry in a Householder vector.Fields inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
applyUpdate, householderVector, minAxisSize, numCols, numRows, qFactors, storeReflectors, subDiagonal, transformData, transformMatrix, workArray
-
Constructor Summary
ConstructorDescriptionComplexUnitaryDecomposition
(int subDiagonal) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which is has zeros below the specified sub-diagonal.ComplexUnitaryDecomposition
(int subDiagonal, boolean storeReflectors) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which is has zeros below the specified sub-diagonal. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
computeHouseholder
(int j) Computes the Householder vector for the first column of the sub-matrix with upper left corner at(j, j)
.protected void
computePhasedNorm
(int j, double maxAbs) Computes the norm of columnj
below thej
th row of the matrix to be decomposed.protected double
findMaxAndInit
(int j) Finds the maximum value inUnitaryDecomposition.transformMatrix
at columnj
at or below thej
th row.getQ()
Gets the unitaryQ
matrix from theQR
decomposition.protected CMatrix
Gets the upper triangular/Hessenburg matrix from the last decomposition.protected void
initWorkArrays
(int maxAxisSize) Initialized any work arrays to be used in computing the decomposition with the proper size.protected void
updateData
(int j) Updates theUnitaryDecomposition.transformMatrix
matrix using the computed Householder vector fromcomputeHouseholder(int)
.Methods inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
decomposeBase, getUpper, initQ, setUp
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.flag4j.linalg.decompositions.Decomposition
decompose
-
Field Details
-
normRe
protected double normReTo store norms of columns inUnitaryDecomposition.transformMatrix
. Will be real. -
norm
For storing the scaled, phase-adjusted norm. This may be complex. -
currentFactor
Scalar factor of the currently computed Householder reflector. -
shift
Stores the shifted value of the first entry in a Householder vector.
-
-
Constructor Details
-
ComplexUnitaryDecomposition
public ComplexUnitaryDecomposition(int subDiagonal) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which is has zeros below the specified sub-diagonal.- Parameters:
subDiagonal
- Sub-diagonal of the upper triangular/Hessenburg matrix. That is, the sub-diagonal for which all entries below will be zero in the final upper quasi-triangular matrix. Must be Zero or one. If zero, it will be upper triangular. If one, it will be upper Hessenburg.
-
ComplexUnitaryDecomposition
public ComplexUnitaryDecomposition(int subDiagonal, boolean storeReflectors) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which is has zeros below the specified sub-diagonal.Allows for specification if the reflectors used to bring matrix to upper triangular/Hessenburg form to be stored or not.
If the
Q
matrix is need, thenstoreReflectors
must be true. IfQ
is NOT needed, then not storing the reflectors may improve performance slightly by avoiding unneeded copies.It should be noted that if performance is improved, it will be a very slight improvement compared to the total time to compute the decomposition. This is because the computation of
Q
is only evaluated lazily oncegetQ()
is called, so this will only save on copy operations.- Parameters:
subDiagonal
- Sub-diagonal of the upper triangular/Hessenburg matrix. That is, the sub-diagonal for which all entries below will be zero in the final upper quasi-triangular matrix. Must be Zero or one. If zero, it will be upper triangular. If one, it will be upper Hessenburg.storeReflectors
- Flag indicating if the reflectors used to bring the matrix to upper triangular/Hessenburg form should be stored.
-
-
Method Details
-
getQ
Gets the unitary
Q
matrix from theQR
decomposition.Note, if the reflectors for this decomposition were not saved, then
Q
can not be computed and this method will be null.- Specified by:
getQ
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Returns:
- The
Q
matrix from theQR
decomposition. Note, if the reflectors for this decomposition were not saved, thenQ
can not be computed and this method will returnnull
.
-
getUpper
Gets the upper triangular/Hessenburg matrix from the last decomposition.- Specified by:
getUpper
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Parameters:
H
- Storage for upper triangular/Hessenburg matrix. Assumed to be the zero matrix of an appropriate size.- Returns:
- The upper triangular/Hessenburg matrix from the last decomposition.
-
initWorkArrays
protected void initWorkArrays(int maxAxisSize) Initialized any work arrays to be used in computing the decomposition with the proper size.- Specified by:
initWorkArrays
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Parameters:
maxAxisSize
- Length of the largest axis in the matrix to be decomposed. That is,max(numRows, numCols)
-
computeHouseholder
protected void computeHouseholder(int j) Computes the Householder vector for the first column of the sub-matrix with upper left corner at(j, j)
.- Specified by:
computeHouseholder
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Parameters:
j
- Index of the upper left corner of the sub-matrix for which to compute the Householder vector for the first column. That is, a Householder vector will be computed for the portion of columnj
below rowj
.
-
computePhasedNorm
protected void computePhasedNorm(int j, double maxAbs) Computes the norm of columnj
below thej
th row of the matrix to be decomposed. The norm will have the same parity as the first entry in the sub-column.- Specified by:
computePhasedNorm
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Parameters:
j
- Column to compute norm of below thej
th row.maxAbs
- Maximum absolute value in the column. Used for scaling norm to minimize potential overflow issues.
-
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.- Specified by:
findMaxAndInit
in classUnitaryDecomposition<CMatrix,
CNumber[]> - 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.
-
updateData
protected void updateData(int j) Updates theUnitaryDecomposition.transformMatrix
matrix using the computed Householder vector fromcomputeHouseholder(int)
.- Specified by:
updateData
in classUnitaryDecomposition<CMatrix,
CNumber[]> - Parameters:
j
- Index of sub-matrix for which the Householder reflector was computed for.
-