|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math3.linear.QRDecomposition
public class QRDecomposition
Calculates the QR-decomposition of a matrix.
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
.
Nested Class Summary | |
---|---|
private static class |
QRDecomposition.Solver
Specialized solver. |
Field Summary | |
---|---|
private RealMatrix |
cachedH
Cached value of H. |
private RealMatrix |
cachedQ
Cached value of Q. |
private RealMatrix |
cachedQT
Cached value of QT. |
private RealMatrix |
cachedR
Cached value of R. |
private double[][] |
qrt
A packed TRANSPOSED representation of the QR decomposition. |
private double[] |
rDiag
The diagonal elements of R. |
private double |
threshold
Singularity threshold. |
Constructor Summary | |
---|---|
QRDecomposition(RealMatrix matrix)
Calculates the QR-decomposition of the given matrix. |
|
QRDecomposition(RealMatrix matrix,
double threshold)
Calculates the QR-decomposition of the given matrix. |
Method Summary | |
---|---|
protected void |
decompose(double[][] matrix)
Decompose matrix. |
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. |
DecompositionSolver |
getSolver()
Get a solver for finding the A × X = B solution in least square sense. |
protected void |
performHouseholderReflection(int minor,
double[][] matrix)
Perform Householder reflection for a minor A(minor, minor) of A. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private double[][] qrt
The elements BELOW the diagonal are the elements of the UPPER triangular matrix R, and the rows ABOVE the diagonal are the Householder reflector vectors from which an explicit form of Q can be recomputed if desired.
private double[] rDiag
private RealMatrix cachedQ
private RealMatrix cachedQT
private RealMatrix cachedR
private RealMatrix cachedH
private final double threshold
Constructor Detail |
---|
public QRDecomposition(RealMatrix matrix)
matrix
- The matrix to decompose.QRDecomposition(RealMatrix,double)
public QRDecomposition(RealMatrix matrix, double threshold)
matrix
- The matrix to decompose.threshold
- Singularity threshold.Method Detail |
---|
protected void decompose(double[][] matrix)
matrix
- transposed matrixprotected void performHouseholderReflection(int minor, double[][] matrix)
minor
- minor indexmatrix
- transposed matrixpublic RealMatrix getR()
R is an upper-triangular matrix
public 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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |