Class RealQR


public class RealQR extends RealUnitaryDecomposition

Computes the QR decomposition of a real dense matrix.

The QR decomposition factorizes a given matrix \( A \) into the product of an orthogonal matrix \( Q \) and an upper triangular matrix \( R \), such that: \[ A = QR \]

The decomposition can be computed in either the full or reduced form:

  • Reduced QR decomposition: When reduced = true, the decomposition produces a compact form where \( Q \) has the same number of rows as \( A \) but only as many columns as the rank of \( A \).
  • Full QR decomposition: When reduced = false, the decomposition produces a square orthogonal matrix \( Q \) with the same number of rows as \( A \).

Usage:

The decomposition workflow typically follows these steps:
  1. Instantiate an instance of RealQR.
  2. Call decompose(Matrix) to perform the factorization.
  3. Retrieve the resulting matrices using RealUnitaryDecomposition.getQ() and getR().
See Also:
  • Field Details

    • reduced

      protected final boolean reduced
      Flag indicating if the reduced or full decomposition should be computed.
      • If true: the reduced decomposition will be computed.
      • If false: the full decomposition will be computed.
  • Constructor Details

    • RealQR

      public RealQR()
      Creates a QR decomposer. This decomposer will compute the reduced QR decomposition.
      See Also:
    • RealQR

      public RealQR(boolean reduced)
      Creates a QR decomposer to compute either the full or reduced QR decomposition.
      Parameters:
      reduced - Flag indicating if the reduced or full decomposition should be computed.
      • If true: the reduced decomposition will be computed.
      • If false: the full decomposition will be computed.
  • Method Details

    • decompose

      public RealQR decompose(Matrix src)
      Computes the QR decomposition of the provided matrix.
      Overrides:
      decompose in class UnitaryDecomposition<Matrix,double[]>
      Parameters:
      src - The matrix to decompose.
      Returns:
      A reference to this decomposer.
    • initQ

      protected Matrix initQ()
      Creates and initializes the \( Q \) matrix to the appropriately sized identity matrix.
      Specified by:
      initQ in class UnitaryDecomposition<Matrix,double[]>
      Returns:
      An identity matrix with the appropriate size.
    • getUpper

      public Matrix getUpper()
      Gets the upper triangular matrix, \( R \), from the last decomposition. Same as getR().
      Specified by:
      getUpper in class UnitaryDecomposition<Matrix,double[]>
      Returns:
      The upper triangular matrix from the last decomposition.
    • getR

      public Matrix getR()
      Gets the upper triangular matrix, \( R \), from the QR decomposition.
      Returns:
      The upper triangular matrix, \( R \), from the QR decomposition.