org.jmatrices.dbl.decomposition
Class QRDecomposition

java.lang.Object
  extended byorg.jmatrices.dbl.decomposition.QRDecomposition

public class QRDecomposition
extends java.lang.Object

QRDecomposition

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

The code is basically JAMA code with modifications made to fit in the scheme of things.

Author: purangp

Date: 13.03.2004 Time: 13:51:42


Constructor Summary
QRDecomposition(Matrix matrix)
          QR Decomposition, computed by Householder reflections.
 
Method Summary
 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?
 Matrix solve(Matrix B)
          Least squares solution of A*X = B
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QRDecomposition

public QRDecomposition(Matrix matrix)
QR Decomposition, computed by Householder reflections.

Parameters:
matrix - Rectangular matrix Structure to access R and the Householder vectors and compute Q.
Method Detail

isFullRank

public boolean isFullRank()
Is the matrix full rank?

Returns:
true if R, and hence A, has full rank.

getH

public Matrix getH()
Return the Householder vectors

Returns:
Lower trapezoidal matrix whose columns define the reflections

getR

public Matrix getR()
Return the upper triangular factor

Returns:
R

getQ

public Matrix getQ()
Generate and return the (economy-sized) orthogonal factor

Returns:
Q

solve

public Matrix solve(Matrix B)
Least squares solution of A*X = B

Parameters:
B - A Matrix with as many rows as A and any number of columns.
Returns:
X that minimizes the two norm of Q*R*X-B.
Throws:
java.lang.IllegalArgumentException - Matrix row dimensions must agree.
java.lang.RuntimeException - Matrix is rank deficient.