Class QRDecomposition

  • All Implemented Interfaces:
    java.io.Serializable

    public class QRDecomposition
    extends java.lang.Object
    implements java.io.Serializable
    QR Decomposition.

    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 decomposition 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.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      QRDecomposition​(MatrixD A)
      QR Decomposition, computed by Householder reflections.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MatrixD getH()
      Return the Householder vectors
      MatrixD getQ()
      Generate and return the (economy-sized) orthogonal factor
      MatrixD getR()
      Return the upper triangular factor
      boolean isFullRank()
      Is the matrix full rank?
      MatrixD solve​(MatrixD 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​(MatrixD A)
        QR Decomposition, computed by Householder reflections.
        Parameters:
        A - Rectangular matrix Structure to access R and the Householder vectors and compute Q.
    • Method Detail

      • getH

        public MatrixD getH()
        Return the Householder vectors
        Returns:
        Lower trapezoidal matrix whose columns define the reflections
      • getQ

        public MatrixD getQ()
        Generate and return the (economy-sized) orthogonal factor
        Returns:
        Q
      • getR

        public MatrixD getR()
        Return the upper triangular factor
        Returns:
        R
      • isFullRank

        public boolean isFullRank()
        Is the matrix full rank?
        Returns:
        true if R, and hence A, has full rank.
      • solve

        public MatrixD solve​(MatrixD 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.