edu.mines.jtk.la
Class DMatrixQrd

java.lang.Object
  extended by edu.mines.jtk.la.DMatrixQrd

public class DMatrixQrd
extends java.lang.Object

QR decomposition of a matrix A. For an m-by-n matrix A, with m>=n, the QR decomposition is A = Q*R, where Q is an m-by-n orthogonal matrix, and R is an n-by-n upper-triangular matrix.

The QR decomposition is constructed even if the matrix A is rank deficient. However, the primary use of the QR decomposition is for least-squares solutions of non-square systems of linear equations, and such solutions are feasible only if the matrix A is of full rank.

This class was adapted from the package Jama, which was developed by Joe Hicklin, Cleve Moler, and Peter Webb of The MathWorks, Inc., and by Ronald Boisvert, Bruce Miller, Roldan Pozo, and Karin Remington of the National Institue of Standards and Technology.

Version:
2005.12.01
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
DMatrixQrd(DMatrix a)
          Constructs an QR decomposition for the specified matrix A.
 
Method Summary
 DMatrix getQ()
          Gets the m-by-n matrix factor Q.
 DMatrix getR()
          Gets the n-by-n upper triangular matrix factor R.
 boolean isFullRank()
          Determines whether the matrix A = Q*R is of full rank.
 DMatrix solve(DMatrix b)
          Returns the least-squares solution X of the system A*X = B.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DMatrixQrd

public DMatrixQrd(DMatrix a)
Constructs an QR decomposition for the specified matrix A. The matrix A must not have more columns than rows. If A is m-by-n, then, m>=n is required.

Parameters:
a - the matrix A.
Method Detail

isFullRank

public boolean isFullRank()
Determines whether the matrix A = Q*R is of full rank.

Returns:
true, if full rank; false, otherwise.

getQ

public DMatrix getQ()
Gets the m-by-n matrix factor Q.

Returns:
the m-by-n matrix factor Q.

getR

public DMatrix getR()
Gets the n-by-n upper triangular matrix factor R.

Returns:
the n-by-n matrix factor R.

solve

public DMatrix solve(DMatrix b)
Returns the least-squares solution X of the system A*X = B. This solution exists only if the matrix A is of full rank.

Parameters:
b - a matrix of right-hand-side vectors. This matrix must have the same number (m) of rows as the matrix A, but may have any number of columns.
Returns:
the matrix X that minimizes the two-norm of A*X-B.
Throws:
java.lang.IllegalStateException - if A is rank-deficient.