Record Class LUResult<E>

java.lang.Object
java.lang.Record
org.episteme.core.mathematics.linearalgebra.matrices.solvers.LUResult<E>
Type Parameters:
E - the element type
Record Components:
L - the lower triangular matrix
U - the upper triangular matrix
P - the permutation vector

public record LUResult<E>(Matrix<E> L, Matrix<E> U, Vector<E> P) extends Record
Result of an LU decomposition.

P * A = L * U

  • Constructor Details

    • LUResult

      public LUResult(Matrix<E> L, Matrix<E> U, Vector<E> P)
      Creates an instance of a LUResult record class.
      Parameters:
      L - the value for the L record component
      U - the value for the U record component
      P - the value for the P record component
  • Method Details

    • getL

      public Matrix<E> getL()
    • getU

      public Matrix<E> getU()
    • getP

      public Vector<E> getP()
    • reconstruct

      public Matrix<E> reconstruct()
      Reconstructs the matrix A (as permuted by P).

      Returns P * A = L * U.

      Returns:
      the reconstructed matrix L * U
    • getOriginalA

      public Matrix<E> getOriginalA()
      Reconstructs the original matrix A (un-permuted).
      Returns:
      the original matrix A
    • solve

      public Vector<E> solve(Vector<E> b)
      Solves the system A * x = b using the LU decomposition results.
      Parameters:
      b - the right-hand side vector
      Returns:
      the solution vector x
      Throws:
      IllegalArgumentException - if dimensions mismatch
      UnsupportedOperationException - if the ring is not a Field
      ArithmeticException - if the matrix is singular
    • 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.
    • L

      public Matrix<E> L()
      Returns the value of the L record component.
      Returns:
      the value of the L record component
    • U

      public Matrix<E> U()
      Returns the value of the U record component.
      Returns:
      the value of the U record component
    • P

      public Vector<E> P()
      Returns the value of the P record component.
      Returns:
      the value of the P record component