SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.factorization.qr
Class QR

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.factorization.qr.QR
All Implemented Interfaces:
QRDecomposition

public class QR
extends java.lang.Object
implements QRDecomposition

QR decomposition of a matrix decomposes an m x n matrix A so that A = Q * R.

Alternatively, we can have A = sqQ * tallR, where

See Also:
Wikipedia: QR decomposition

Constructor Summary
QR(Matrix A)
          Run the QR decomposition on a matrix.
QR(Matrix A, double epsilon)
          Run the QR decomposition on a matrix.
 
Method Summary
 PermutationMatrix P()
          Get P, the pivoting matrix in the QR decomposition.
 Matrix Q()
          Get the orthogonal Q matrix in the QR decomposition, A = QR.
 UpperTriangularMatrix R()
          Get the upper triangular matrix R in the QR decomposition, A = QR.
 int rank()
          Get the numerical rank of A as computed by the QR decomposition.
 Matrix squareQ()
          Get the square Q matrix.
 Matrix tallR()
          Get the tall R matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QR

public QR(Matrix A,
          double epsilon)
Run the QR decomposition on a matrix.

Parameters:
A - a matrix
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0

QR

public QR(Matrix A)
Run the QR decomposition on a matrix.

Parameters:
A - a matrix
Method Detail

P

public PermutationMatrix P()
Description copied from interface: QRDecomposition
Get P, the pivoting matrix in the QR decomposition.

Specified by:
P in interface QRDecomposition
Returns:
P

Q

public Matrix Q()
Description copied from interface: QRDecomposition
Get the orthogonal Q matrix in the QR decomposition, A = QR. The dimension of Q is m x n, the same as A, the matrix to be orthogonalized.

Specified by:
Q in interface QRDecomposition
Returns:
Q

R

public UpperTriangularMatrix R()
Description copied from interface: QRDecomposition
Get the upper triangular matrix R in the QR decomposition, A = QR. The dimension of R is n x n, a square matrix.

Specified by:
R in interface QRDecomposition
Returns:
R

rank

public int rank()
Description copied from interface: QRDecomposition
Get the numerical rank of A as computed by the QR decomposition. Numerical determination of rank requires a criterion to decide when a value should be treated as zero, hence a precision parameter. This is a practical choice which depends on both the matrix and the application. For instance, for a matrix with a big first eigenvector, we should accordingly decrease the precision to compute the rank.

Specified by:
rank in interface QRDecomposition
Returns:
the rank of A

squareQ

public Matrix squareQ()
Description copied from interface: QRDecomposition
Get the square Q matrix. This is an arbitrary orthogonal completion of the Q matrix in the QR decomposition. The dimension is m x m (square). We have A = sqQ * tallR.

Specified by:
squareQ in interface QRDecomposition
Returns:
the square Q matrix

tallR

public Matrix tallR()
Description copied from interface: QRDecomposition
Get the tall R matrix. This is completed by binding zero rows beneath the square upper triangular matrix R in the QR decomposition. The dimension is m x n. It may not be square. We have A = sqQ * tallR.

Specified by:
tallR in interface QRDecomposition
Returns:
the tall R matrix

SuanShu, a Java numerical and statistical library

Copyright © 2012 Numerical Method Inc. Ltd. All Rights Reserved.