Record Class SVDResult

java.lang.Object
java.lang.Record
de.labathome.trustconstr.matrix.SVDResult

public record SVDResult(DenseMatrix U, double[] s, DenseMatrix Vt) extends Record
Singular-value decomposition A = U * diag(s) * V^T.

Shapes:

  • U is m x m
  • s has length min(m, n); values are non-negative and monotonically non-increasing (LAPACK convention)
  • Vt is n x n (already transposed -- i.e. V^T from the textbook decomposition; rows are right-singular vectors)
  • Constructor Summary

    Constructors
    Constructor
    Description
    SVDResult(DenseMatrix U, double[] s, DenseMatrix Vt)
    Creates an instance of a SVDResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    rank(double tol)
    Number of singular values strictly greater than tol.
    double[]
    Element-wise reciprocal of the singular values, with values at or below the LAPACK numerical-zero threshold max(m,n) * ulp(sigma_max) mapped to 0.
    double[]
    s()
    Returns the value of the s record component.
    final String
    Returns a string representation of this record class.
    U()
    Returns the value of the U record component.
    Vt()
    Returns the value of the Vt record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SVDResult

      public SVDResult(DenseMatrix U, double[] s, DenseMatrix Vt)
      Creates an instance of a SVDResult record class.
      Parameters:
      U - the value for the U record component
      s - the value for the s record component
      Vt - the value for the Vt record component
  • Method Details

    • rank

      public int rank(double tol)
      Number of singular values strictly greater than tol. Use the LAPACK convention tol = max(m,n) * ulp(sigma_max) for numerical rank if no problem-specific cutoff is known.
      Parameters:
      tol - singular-value cutoff
      Returns:
      numerical rank
    • reciprocalSingularValues

      public double[] reciprocalSingularValues()
      Element-wise reciprocal of the singular values, with values at or below the LAPACK numerical-zero threshold max(m,n) * ulp(sigma_max) mapped to 0. Use this when forming A^+ = V * diag(1/s) * U^T.
      Returns:
      length-min(m, n) reciprocal singular values, with entries below the cutoff zeroed out
    • 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.
    • U

      public DenseMatrix U()
      Returns the value of the U record component.
      Returns:
      the value of the U record component
    • s

      public double[] s()
      Returns the value of the s record component.
      Returns:
      the value of the s record component
    • Vt

      public DenseMatrix Vt()
      Returns the value of the Vt record component.
      Returns:
      the value of the Vt record component