public class QRDecomposition extends Object implements Decomposition
The QR-decomposition of a matrix A consists of two matrices Q and R that satisfy: A = QR, Q is orthogonal (QTQ = I), and R is upper triangular. If A is m×n, Q is m×m and R m×n.
This class compute the decomposition using Householder reflectors.
For efficiency purposes, the decomposition in packed form is transposed. This allows inner loop to iterate inside rows, which is much more cache-efficient in Java.
This class is based on the class with similar name from the JAMA library, with the following changes:
getQT method has been added,solve and isFullRank methods have been replaced by a getSolver method
and the equivalent methods provided by the returned DecompositionSolver.This class is up-to-date with commons-math 3.6.1.
| Constructor and Description |
|---|
QRDecomposition(RealMatrix matrix)
Simple constructor.
|
QRDecomposition(RealMatrix matrix,
double inThreshold)
Constructor used to set the singularity threshold.
|
QRDecomposition(RealMatrix matrix,
double thresholdIn,
boolean parallel)
Constructor used to set the singularity threshold and enable parallel computation.
|
| Modifier and Type | Method and Description |
|---|---|
static Function<RealMatrix,Decomposition> |
decompositionBuilder(double thresholdIn)
Builder for decomposition.
|
static Function<RealMatrix,Decomposition> |
decompositionBuilder(double thresholdIn,
boolean parallel)
Builder for decomposition.
|
RealMatrix |
getH()
Returns the Householder reflector vectors.
|
RealMatrix |
getQ()
Returns the matrix Q of the decomposition.
|
RealMatrix |
getQT()
Returns the transpose of the matrix Q of the decomposition.
|
RealMatrix |
getR()
Returns the matrix R of the decomposition.
|
RealMatrix |
getR(boolean compactForm)
Returns the matrix R of the decomposition in its compact form (n × n) or in its full form
(m × n).
|
DecompositionSolver |
getSolver()
Gets a solver for finding the A × X = B solution in exact linear sense.
|
public QRDecomposition(RealMatrix matrix)
The decomposition is directly computed on the input matrix
matrix - The matrix to decompose.QRDecomposition(RealMatrix, double, boolean)public QRDecomposition(RealMatrix matrix, double inThreshold)
The decomposition is directly computed on the input matrix
matrix - The matrix to decompose.thresholdIn - Singularity threshold.QRDecomposition(RealMatrix, double, boolean)public QRDecomposition(RealMatrix matrix, double thresholdIn, boolean parallel)
The decomposition is directly computed on the input matrix
matrix - The matrix to decompose.thresholdIn - Singularity threshold.parallel - Indicate if a part of the algorithm can be parallelized. It is advised to activate this for big matrices only. Indeed, for
small matrices the multi-thread management overload might be disadvantageous.public RealMatrix getR()
R is an upper-triangular matrix
public RealMatrix getR(boolean compactForm)
R is an upper-triangular matrix
compactForm - if true R dimensions will be n × n, else R dimensions will be
m × npublic RealMatrix getQ()
Q is an orthogonal matrix
public RealMatrix getQT()
Q is an orthogonal matrix
public RealMatrix getH()
H is a lower trapezoidal matrix whose columns represent each successive Householder reflector vector. This matrix is used to compute Q.
public DecompositionSolver getSolver()
Least Square sense means a solver can be computed for an overdetermined system,
(i.e. a system with more equations than unknowns, which corresponds to a tall A
matrix with more rows than columns). In any case, if the matrix is singular
within the tolerance set at construction, an error will be triggered when
the solve method will be called.
getSolver in interface Decompositionpublic static Function<RealMatrix,Decomposition> decompositionBuilder(double thresholdIn)
thresholdIn - Singularity threshold.public static Function<RealMatrix,Decomposition> decompositionBuilder(double thresholdIn, boolean parallel)
thresholdIn - Singularity threshold.parallel - Indicate if a part of the algorithm can be performed in parallelCopyright © 2025 CNES. All rights reserved.