Class RealQR
java.lang.Object
org.flag4j.linalg.decompositions.Decomposition<Matrix>
org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition<Matrix,double[]>
org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
org.flag4j.linalg.decompositions.qr.RealQR
Computes the QR decomposition of a real dense matrix.
The QR decomposition factorizes a given matrix \( A \) into the product of an orthogonal matrix \( Q \) and an upper triangular matrix \( R \), such that: \[ A = QR \]
The decomposition can be computed in either the full or reduced form:
- Reduced QR decomposition: When
reduced = true
, the decomposition produces a compact form where \( Q \) has the same number of rows as \( A \) but only as many columns as the rank of \( A \). - Full QR decomposition: When
reduced = false
, the decomposition produces a square orthogonal matrix \( Q \) with the same number of rows as \( A \).
Usage:
The decomposition workflow typically follows these steps:- Instantiate an instance of
RealQR
. - Call
decompose(Matrix)
to perform the factorization. - Retrieve the resulting matrices using
RealUnitaryDecomposition.getQ()
andgetR()
.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
Flag indicating if the reduced or full decomposition should be computed.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, iHigh, iLow, inPlace, minAxisSize, numCols, numRows, qFactors, storeReflectors, subDiagonal, transformData, transformMatrix, workArray
Fields inherited from class org.flag4j.linalg.decompositions.Decomposition
hasDecomposed
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComputes the QR decomposition of the provided matrix.getR()
Gets the upper triangular matrix, \( R \), from the QR decomposition.getUpper()
Gets the upper triangular matrix, \( R \), from the last decomposition.protected Matrix
initQ()
Creates and initializes the \( Q \) matrix to the appropriately sized identity matrix.Methods inherited from class org.flag4j.linalg.decompositions.unitary.RealUnitaryDecomposition
computeHouseholder, computePhasedNorm, findMaxAndInit, getQ, getUpper, initWorkArrays, updateData
Methods inherited from class org.flag4j.linalg.decompositions.unitary.UnitaryDecomposition
decompose, setUp
Methods inherited from class org.flag4j.linalg.decompositions.Decomposition
ensureHasDecomposed
-
Field Details
-
reduced
protected final boolean reducedFlag indicating if the reduced or full decomposition should be computed.- If
true
: the reduced decomposition will be computed. - If
false
: the full decomposition will be computed.
- If
-
-
Constructor Details
-
RealQR
public RealQR()Creates a QR decomposer. This decomposer will compute the reduced QR decomposition.- See Also:
-
RealQR
public RealQR(boolean reduced) Creates a QR decomposer to compute either the full or reduced QR decomposition.- Parameters:
reduced
- Flag indicating if the reduced or full decomposition should be computed.- If
true
: the reduced decomposition will be computed. - If
false
: the full decomposition will be computed.
- If
-
-
Method Details
-
decompose
Computes the QR decomposition of the provided matrix.- Overrides:
decompose
in classUnitaryDecomposition<Matrix,
double[]> - Parameters:
src
- The matrix to decompose.- Returns:
- A reference to this decomposer.
-
initQ
Creates and initializes the \( Q \) matrix to the appropriately sized identity matrix.- Specified by:
initQ
in classUnitaryDecomposition<Matrix,
double[]> - Returns:
- An identity matrix with the appropriate size.
-
getUpper
Gets the upper triangular matrix, \( R \), from the last decomposition. Same asgetR()
.- Specified by:
getUpper
in classUnitaryDecomposition<Matrix,
double[]> - Returns:
- The upper triangular matrix from the last decomposition.
-
getR
Gets the upper triangular matrix, \( R \), from the QR decomposition.- Returns:
- The upper triangular matrix, \( R \), from the QR decomposition.
-