Class CooTranspose

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

public final class CooTranspose extends Object
Utility class for computing the transpose of a sparse COO tensor or matrix.
  • Method Details

    • tensorTranspose

      public static void tensorTranspose(Shape shape, Object[] srcEntries, int[][] srcIndices, int axis1, int axis2, Object[] destEntries, int[][] destIndices)

      Computes the transpose of a sparse COO tensor by exchanging axis1 and axis2.

      Parameters:
      shape - Shape of the tensor to transpose.
      srcEntries - The non-zero data of the tensor to transpose.
      srcIndices - The non-zero indices of the tensor to transpose. Must have shape [srcEntries.length][shape.getRank()].
      axis1 - First axis to exchange. Must be in the range [0, shape.getRank()).
      axis2 - Second axis to exchange. Must be in the range [0, shape.getRank()).
      destEntries - Array to store the non-zero data of the transpose. Must have the same length as srcEntries.
      destIndices - Array to store the non-zero indices of the transpose. Must have shape [srcEntries.length][shape.getRank()]
      srcIndices -
      Throws:
      IndexOutOfBoundsException - If either axis1 or axis2 are out of bounds for the rank of this tensor.
      See Also:
    • tensorTranspose

      public static void tensorTranspose(Shape shape, Object[] srcEntries, int[][] srcIndices, int[] axes, Object[] destEntries, int[][] destIndices)
      Computes the transpose of a sparse COO tensor. That is, permutes the axes of the tensor so that it matches the permutation specified by axes.
      Parameters:
      shape - Shape of the tensor to transpose.
      srcEntries - The non-zero data of the tensor to transpose.
      srcIndices - The non-zero indices of the tensor to transpose. Must have shape [srcEntries.length][shape.getRank()].
      axes - Permutation of tensor axis. If the tensor has rank N, then this must be an array of length N which is a permutation of {0, 1, 2, ..., N-1}.
      destEntries - Array to store the non-zero data of the transpose. Must have the same length as srcEntries.
      destIndices - Array to store the non-zero indices of the transpose. Must have shape [srcEntries.length][shape.getRank()]
      Throws:
      IllegalArgumentException - If srcEntries, srcIndices, destEntries, and destIndices do not all have the same length.
      IndexOutOfBoundsException - If any element of axes is out of bounds for the rank of this tensor.
      IllegalArgumentException - If axes is not a permutation of {1, 2, 3, ... N-1}.