Record Class QR

Record Components:
qr - the QR decomposition.
tau - the scalar factors of the elementary reflectors.
All Implemented Interfaces:
Serializable

public record QR(DenseMatrix qr, Vector tau) extends Record implements Serializable
The 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 such that A = Q*R.

The QR decomposition always exists, even if the matrix does not have full rank. The primary use of the QR decomposition is in the least squares solution of non-square systems of simultaneous linear equations.

See Also:
  • Constructor Details

    • QR

      public QR(DenseMatrix qr, Vector tau)
      Creates an instance of a QR record class.
      Parameters:
      qr - the value for the qr record component
      tau - the value for the tau record component
  • Method Details

    • toCholesky

      public Cholesky toCholesky()
      Returns the Cholesky decomposition of A'A.
      Returns:
      the Cholesky decomposition of A'A.
    • R

      public DenseMatrix R()
      Returns the upper triangular factor.
      Returns:
      the upper triangular factor.
    • Q

      public DenseMatrix Q()
      Returns the orthogonal factor.
      Returns:
      the orthogonal factor.
    • solve

      public Vector solve(double[] b)
      Solves the least squares min || B - A*X ||.
      Parameters:
      b - the right hand side of overdetermined linear system.
      Returns:
      the solution vector.
      Throws:
      RuntimeException - when the matrix is rank deficient.
    • solve

      public Vector solve(float[] b)
      Solves the least squares min || B - A*X ||.
      Parameters:
      b - the right hand side of overdetermined linear system.
      Returns:
      the solution vector.
      Throws:
      RuntimeException - when the matrix is rank deficient.
    • solve

      public void solve(DenseMatrix B)
      Solves the least squares min || B - A*X ||.
      Parameters:
      B - the right hand side of overdetermined linear system. B will be overwritten with the solution matrix on output.
      Throws:
      RuntimeException - when the matrix is rank deficient.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • qr

      public DenseMatrix qr()
      Returns the value of the qr record component.
      Returns:
      the value of the qr record component
    • tau

      public Vector tau()
      Returns the value of the tau record component.
      Returns:
      the value of the tau record component