public class QRDecomposition extends Object implements Serializable
For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by-n upper triangular matrix R so that A = Q*R.
The QR decompostion always exists, even if the matrix does not have full rank, so the constructor will never fail. The primary use of the QR decomposition is in the least squares solution of nonsquare systems of simultaneous linear equations. This will fail if isFullRank() returns false.
Modifier and Type | Field and Description |
---|---|
private int |
m
Row and column dimensions.
|
private int |
n
Row and column dimensions.
|
private double[][] |
QR
Array for internal storage of decomposition.
|
private double[] |
Rdiag
Array for internal storage of diagonal of R.
|
private static long |
serialVersionUID
Serial version
|
Constructor and Description |
---|
QRDecomposition(double[][] A,
int m,
int n)
QR Decomposition, computed by Householder reflections.
|
QRDecomposition(Matrix A)
QR Decomposition, computed by Householder reflections.
|
Modifier and Type | Method and Description |
---|---|
Matrix |
getH()
Return the Householder vectors
|
Matrix |
getQ()
Generate and return the (economy-sized) orthogonal factor
|
Matrix |
getR()
Return the upper triangular factor
|
boolean |
isFullRank()
Is the matrix full rank?
|
double[][] |
solve(double[][] B)
Least squares solution of A*X = B
|
Matrix |
solve(Matrix B)
Least squares solution of A*X = B
|
private void |
solveInplace(double[][] X,
int nx) |
private static final long serialVersionUID
private double[][] QR
private int m
private int n
private double[] Rdiag
public QRDecomposition(Matrix A)
A
- Rectangular matrixpublic QRDecomposition(double[][] A, int m, int n)
A
- Rectangular matrixm
- row dimensionalityn
- column dimensionalitypublic boolean isFullRank()
public Matrix getH()
public Matrix getR()
public Matrix getQ()
public Matrix solve(Matrix B)
B
- A Matrix with as many rows as A and any number of columns.IllegalArgumentException
- Matrix row dimensions must agree.RuntimeException
- Matrix is rank deficient.public double[][] solve(double[][] B)
B
- A Matrix with as many rows as A and any number of columns.IllegalArgumentException
- Matrix row dimensions must agree.RuntimeException
- Matrix is rank deficient.private void solveInplace(double[][] X, int nx)
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.