Record Class SparseTensorData<T>

java.lang.Object
java.lang.Record
org.flag4j.arrays.SparseTensorData<T>
Type Parameters:
T - Type of the data of the tensor.
Record Components:
shape - Shape of the tensor.
data - Non-zero data of the sparse tensor.
indices - Non-zero indices of the sparse tensor.

public record SparseTensorData<T>(Shape shape, List<T> data, List<int[]> indices) extends Record

Data class for storing information for a sparse COO tensor.

This record stores two arrays: the non-zero data, the non-zero indices.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SparseTensorData(Shape shape, List<T> data, List<int[]> indices)
    Creates an instance of a SparseTensorData record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the data record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    List<int[]>
    Returns the value of the indices record component.
    int[][]
    Converts the indices of this sparse tensor data to a 2D primitive integer array.
    Returns the value of the shape record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • SparseTensorData

      public SparseTensorData(Shape shape, List<T> data, List<int[]> indices)
      Creates an instance of a SparseTensorData record class.
      Parameters:
      shape - the value for the shape record component
      data - the value for the data record component
      indices - the value for the indices record component
  • Method Details

    • indicesToArray

      public int[][] indicesToArray()
      Converts the indices of this sparse tensor data to a 2D primitive integer array.
      Returns:
      A 2D primitive integer array containing the indices of this sparse tensor data.
    • 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.
    • shape

      public Shape shape()
      Returns the value of the shape record component.
      Returns:
      the value of the shape record component
    • data

      public List<T> data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • indices

      public List<int[]> indices()
      Returns the value of the indices record component.
      Returns:
      the value of the indices record component