Class CooConversions

java.lang.Object
org.flag4j.linalg.ops.sparse.coo.CooConversions

public final class CooConversions extends Object
Utility class for converting COO tensor to another type of tensor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> void
    toCsr(Shape shape, T[] entries, int[] rowIndices, int[] colIndices, T[] destEntries, int[] destRowPointers, int[] destColIndices)
    Converts a COO matrix to an equivalent CSR matrix.
    static <T> void
    toDense(Shape shape, T[] entries, int[][] indices, T[] dest)
    Converts a sparse COO tensor to an equivalent dense tensor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toDense

      public static <T> void toDense(Shape shape, T[] entries, int[][] indices, T[] dest)
      Converts a sparse COO tensor to an equivalent dense tensor.
      Parameters:
      shape - Shape of the COO tensor.
      entries - Non-zero data of the COO tensor.
      indices - Non-zero indices of the COO tensor.
      dest - Array to store the dense result in.
      Throws:
      IllegalArgumentException - If dest.length != shape.totalEntriesIntValueExact().
    • toCsr

      public static <T> void toCsr(Shape shape, T[] entries, int[] rowIndices, int[] colIndices, T[] destEntries, int[] destRowPointers, int[] destColIndices)
      Converts a COO matrix to an equivalent CSR matrix.
      Parameters:
      shape - Shape of the COO matrix.
      entries - Non-zero data of the COO matrix.
      rowIndices - Non-zero row indices of the COO matrix.
      colIndices - Non-zero column indices of the COO matrix.
      destEntries - Array to store non-zero data of the CSR matrix.
      destRowPointers - Array to store non-zero row pointers of the CSR matrix.
      destColIndices - Array to store non-zero column indices of the CSR matrix.