Class RealUnitaryDecomposition
- All Implemented Interfaces:
Decomposition<Matrix>
QR
and Hessenburg
decompositions.-
Field Summary
Modifier and TypeFieldDescriptionprotected double
Scalar factor of the currently computed Householder reflector.protected double
To store norms of columns inUnitaryDecomposition.transformMatrix
.protected double
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
ConstructorDescriptionRealUnitaryDecomposition
(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.RealUnitaryDecomposition
(int subDiagonal, boolean storeReflectors) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which has zeros below the specified sub-diagonal (must be 0 or 1). -
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 the unitary decomposition.protected Matrix
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
-
norm
protected double normTo store norms of columns inUnitaryDecomposition.transformMatrix
. -
currentFactor
protected double currentFactorScalar factor of the currently computed Householder reflector. -
shift
protected double shiftStores the shifted value of the first entry in a Householder vector.
-
-
Constructor Details
-
RealUnitaryDecomposition
public RealUnitaryDecomposition(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.
-
RealUnitaryDecomposition
public RealUnitaryDecomposition(int subDiagonal, boolean storeReflectors) Creates a real unitary decomposer which will reduce the matrix to an upper triangular/Hessenburg matrix which has zeros below the specified sub-diagonal (must be 0 or 1).Allows for specification if the reflectors used to bring matrix to upper triangular/Hessenburg form are 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 the unitary 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<Matrix,
double[]> - Returns:
- The
Q
matrix from the unitary 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<Matrix,
double[]> - 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<Matrix,
double[]> - 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<Matrix,
double[]> - 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<Matrix,
double[]> - 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<Matrix,
double[]> - 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<Matrix,
double[]> - Parameters:
j
- Index of sub-matrix for which the Householder reflector was computed for.
-