SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.factorization.eigen
Class QRAlgorithm

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.factorization.eigen.QRAlgorithm

public class QRAlgorithm
extends java.lang.Object

The QR algorithm is an eigenvalue algorithm that computes the real Schur canonical form of a matrix. That is,

Q'MQ = T
where Q is orthogonal, and T is quasi-triangular.

The eigenvalues of A are the same as those of the diagonal blocks in T.

The basic idea is to perform the QR decomposition, writing the matrix as a product of an orthogonal matrix and an upper triangular matrix, multiply the factors in the other order, and iterate.

This implementation is the implicit double-shift version. It makes the use of multiple shifts easier to introduce. The matrix is first brought to upper Hessenberg form A0 = QAQ' as in the explicit version; then, at each step, the first getColumn of Ak is transformed via a small-size Householder similarity transformation to the first getColumn of p(Ak)e1, where p(Ak), of degree r, is the polynomial that defines the shifting strategy.

Then successive Householder transformation of size r + 1 are performed in order to return the working matrix Ak to upper Hessenberg form. This operation is known as bulge chasing, due to the peculiar shape of the non-zero entries of the matrix along the steps of the algorithm. As in the first version, deflation is performed as soon as one of the sub-diagonal entries of Ak is sufficiently small.

In our implementation, no QR decompositions are explicitly performed. We instead use Francis algorithm (Francis QR step), as described in Golub and Van Loan.

See Also:
Wikipedia: QR algorithm

Field Summary
 double epsilon
          a precision parameter: when a number |x| ≤ ε, it is considered 0
 
Constructor Summary
QRAlgorithm(Matrix A)
          Construct an instance of the QR algorithm.
QRAlgorithm(Matrix A, int maxIterations, double epsilon)
          Construct an instance of the QR algorithm.
 
Method Summary
 NumberList eigenvalues()
          Get all the eigenvalues.
 Matrix Q()
          Get a copy of the Q matrix as in the real Schur canonical form Q'MQ = T We store all the Qi's produced in the process of the QR algorithm.
 Matrix T()
          Get a copy of the T matrix as in the real Schur canonical form Q'MQ = T T is quasi upper triangular.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

epsilon

public final double epsilon
a precision parameter: when a number |x| ≤ ε, it is considered 0

Constructor Detail

QRAlgorithm

public QRAlgorithm(Matrix A,
                   int maxIterations,
                   double epsilon)
Construct an instance of the QR algorithm.

The algorithm is a convergence algorithm. That is, it stops when either

  1. H becomes quasi-triangular, or
  2. the maximum number of iterations is reached.

Parameters:
A - a matrix
maxIterations - the maximum number of iterations
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
Throws:
java.lang.IllegalArgumentException - if A is not square

QRAlgorithm

public QRAlgorithm(Matrix A)
Construct an instance of the QR algorithm.

The algorithm loops until H becomes quasi-triangular.

Parameters:
A - a matrix
Throws:
java.lang.IllegalArgumentException - if A is not square
Method Detail

eigenvalues

public NumberList eigenvalues()
Get all the eigenvalues. We implemented a modified version of
 Algorithm 7.5.2 in
 Matrix Computations, 3rd edition, by
 Golub G. H., van Loan C. F.
 

Given a Hessenberg matrix,

     | H11 H12 H13 |
 H = | 0   H22 H23 |
     | 0   0   H33 |
 
we compute the real Schur canonical form
Q'HQ = T
where Q is orthogonal, and T is quasi-triangular.

Returns:
the list of eigenvalues

Q

public Matrix Q()
Get a copy of the Q matrix as in the real Schur canonical form
Q'MQ = T

We store all the Qi's produced in the process of the QR algorithm. Q is a product of them. That is,

Q = Q1 %*% ... %*% Qn

Returns:
a copy of Q matrix

T

public Matrix T()
Get a copy of the T matrix as in the real Schur canonical form
Q'MQ = T

T is quasi upper triangular.

Returns:
a copy of T matrix

SuanShu, a Java numerical and statistical library

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