Class QR

  • All Implemented Interfaces:
    QRDecomposition

    public class QR
    extends Object
    implements QRDecomposition
    QR decomposition of a matrix decomposes an m x n matrix A so that A = Q * R.
    • Q is an m x n orthogonal matrix;
    • R is a n x n upper triangular matrix.
    Alternatively, we can have A = sqQ * tallR, where
    • sqQ is a square m x m orthogonal matrix;
    • tallR is a m x n matrix.
    See Also:
    Wikipedia: QR decomposition
    • 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

      • 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