Class VisualNumerics.math.DoubleQR
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class VisualNumerics.math.DoubleQR

java.lang.Object
   |
   +----VisualNumerics.math.DoubleQR

public class DoubleQR
extends Object
QR Decomposition of a matrix of type double.

Constructor Index

 o DoubleQR(double[][])
Construct the QR decomposition of a matrix with elements of type double.

Method Index

 o ipvt()
Return an integer vector containing information about the permutation of the elements of the matrix during pivoting.
 o Q()
Return the orthogonal or unitary matrix Q.
 o R()
Return the upper trapezoidal matrix R.
 o rank()
Return the rank of the matrix used to construct this instance.
 o rank(double)
Return the rank of the matrix given an input tolerance.
 o solve(double[])
Calculate the solution to the least-squares problem Ax = b using information about the QR factorization of A.
 o solve(double[], double)
Calculate the solution to the least-squares problem Ax = b using information about the QR factorization of A and an input tolerance.

Constructors

 o DoubleQR
  public DoubleQR(double x[][]) throws IllegalArgumentException
Construct the QR decomposition of a matrix with elements of type double.
Parameters:
a - Input matrix of type double to be factored.
Throws: IllegalArgumentException
This exception is issued when the row lengths of input matrix a are not equal (i.e. the matrix edges are "jagged".)
Algorithm:
The constructor computes the QR decomposition of a matrix using Householder transformations. The constructor is based on the LINPACK routine DQRDC. The constructor determines an orthogonal matrix Q, a permutation matrix P, and an upper trapezoidal matrix R with nonincreasing diagonal elements such that AP = QR. Pivoting is used.
Example:
import VisualNumerics.math.DoubleQR;
import VisualNumerics.math.MathException;
import java.io.*;
class testDQR {
   public static void main(String args[]) {
      int rnk;
      double q[][], r[][], x[];
      double a[][] = {{ 1.0, 2.0,  4.0},
                      { 1.0, 4.0, 16.0},
                      { 1.0, 6.0, 36.0},
                      { 1.0, 8.0, 64.0}};
      double b[] = {16.99, 57.01, 120.99, 209.01};
      try {
        DoubleQR qr = new DoubleQR(a);
        q = qr.Q();
        r = qr.R();
        x = qr.solve(b);
        rnk = qr.rank();
        //  ... print results ...
      } catch (IOException ioe) {
          System.err.println(ioe.toString());
      } catch (IllegalArgumentException e) {
          System.err.println(e.toString());
      } catch (MathException e) {
          System.err.println(e.toString());
      }
   }
}
	

Methods

 o Q
  public double[][] Q()
Return the orthogonal or unitary matrix Q.
Returns:
A matrix of type double containing the accumulated orthogonal matrix Q from the QR decomposition of the matrix used to construct this instance.
Algorithm:
The DoubleQR constructor computes the QR decomposition of the matrix saving the information needed to reconstruct the Householder transformations. These transformations are accumulated to produce the orthogonal matrix Q.
 o R
  public double[][] R()
Return the upper trapezoidal matrix R.
Returns:
The upper trapezoidal matrix R of the QR decomposition of the matrix used to construct this instance.
Algorithm:
The DoubleQR constructor computes the QR decomposition of the matrix saving the upper trapezoidal R. This method retrieves R.
 o rank
  public int rank()
Return the rank of the matrix used to construct this instance.
Returns:
An int scalar containing the rank of the matrix used to construct this instance.
Algorithm:
The DoubleQR constructor computes the QR decomposition of the matrix. The diagonal elements of R are of nonincreasing magnitude. This method traverses the diagonal starting with the element of largest magnitude counting those elements which have magnitude greater than tol where tol is approximately 2.22e-16. The resulting count is returned as the rank of the matrix.
 o rank
  public int rank(double tol)
Return the rank of the matrix given an input tolerance.
Parameters:
tol - Input scalar of type double used in determining the rank of the matrix used to construct this instance.
Returns:
An int scalar containing the rank of the matrix used to construct this instance.
Algorithm:
The DoubleQR constructor computes the QR decomposition of the matrix. The diagonal elements of R are of nonincreasing magnitude. This method traverses the diagonal starting with the element of largest magnitude counting those elements which have magnitude greater than tol. The resulting count is returned as the rank of the matrix.
 o ipvt
  public int[] ipvt()
Return an integer vector containing information about the permutation of the elements of the matrix during pivoting.
Returns:
An int vector of which the k-th element contains the index of the column of the matrix that has been interchanged into the k-th column. This defines the permutation matrix P.
 o solve
  public double[] solve(double b[]) throws MathException
Calculate the solution to the least-squares problem Ax = b using information about the QR factorization of A.
Parameters:
b - Input vector of type double to be manipulated.
Returns:
Vector of type double containing the permuted solution to Ax = b.
Throws: MathException
This exception is issued when the upper triangular matrix R resulting from the QR factorization is singular.
Algorithm:
The constructor computes the QR decomposition of matrix A using Householder transformations. The rank of A is determined based on the number of diagonal elements with magnitude greater than tol where tol is approximately 2.22e-16. The method is based on the LINPACK routine DQRSL. The constructor determines an orthogonal matrix Q, a permutation matrix P, and an upper trapezoidal matrix R with nonincreasing diagonal elements such that AP = QR. Using the normal equations method and the QR decomposition, the least squares problem is reformulated as R(PTx) = QTb. This method then solves for PTx.
 o solve
  public double[] solve(double b[],
                        double tol) throws MathException
Calculate the solution to the least-squares problem Ax = b using information about the QR factorization of A and an input tolerance.
Parameters:
b - Input vector of type double to be manipulated.
tol - Input scalar of type double used in determining the rank of A.
Returns:
Vector of type double containing the permuted solution to Ax = b.
Throws: MathException
This exception is issued when the upper triangular matrix R resulting from the QR factorization is singular.
Algorithm:
The constructor computes the QR decomposition of a matrix A using Householder transformations. The rank of A is determined based on the number of diagonal elements with magnitude greater than tol. The method is based on the LINPACK routine DQRSL. The constructor determines an orthogonal matrix Q, a permutation matrix P, and an upper trapezoidal matrix R with nonincreasing diagonal elements such that AP = QR. Using the normal equations method and the QR decomposition, the least squares problem is reformulated as R(PTx) = QTb. This method then solves for PTx.

All Packages  Class Hierarchy  This Package  Previous  Next  Index