public class QR
extends java.lang.Object
The QR decomposition always exists, even if the matrix does not have
full rank. The primary use of the QR decomposition is in the least squares
solution of non-square systems of simultaneous linear equations, where
isSingular() has to be false.
QR decomposition is also the basis for a particular eigenvalue algorithm, the QR algorithm.
| Modifier and Type | Field and Description |
|---|---|
protected DenseMatrix |
qr
Array for internal storage of decomposition.
|
protected boolean |
singular
Indicate if the matrix is singular.
|
protected double[] |
tau
The diagonal of R for this implementation.
|
| Constructor and Description |
|---|
QR(DenseMatrix qr,
double[] tau,
boolean singular)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Cholesky |
CholeskyOfAtA()
Returns the Cholesky decomposition of A'A.
|
DenseMatrix |
getQ()
Returns the orthogonal factor.
|
DenseMatrix |
getR()
Returns the upper triangular factor.
|
boolean |
isSingular()
Returns true if the matrix is singular (not full column rank).
|
void |
solve(DenseMatrix B)
Solve the least squares A * X = B.
|
void |
solve(double[] b,
double[] x)
Solve the least squares A*x = b.
|
protected DenseMatrix qr
protected double[] tau
protected boolean singular
public QR(DenseMatrix qr, double[] tau, boolean singular)
public boolean isSingular()
public Cholesky CholeskyOfAtA()
public DenseMatrix getR()
public DenseMatrix getQ()
public void solve(double[] b,
double[] x)
b - right hand side of linear system.x - the output solution vector that minimizes the L2 norm of Q*R*x - b.java.lang.RuntimeException - if matrix is rank deficient.public void solve(DenseMatrix B)
B - right hand side of linear system. B will be overwritten with
the solution matrix on output.java.lang.RuntimeException - Matrix is rank deficient.