Class DenseTranspose

java.lang.Object
org.flag4j.linalg.ops.dense.DenseTranspose

public final class DenseTranspose extends Object
This utility class provides methods for computing the transpose of a dense tensor.
  • Method Details

    • standard

      public static Object[] standard(Object[] src, Shape shape, int axis1, int axis2, Object[] dest)
      Transposes tensor along specified axes using a standard transpose algorithm. In this context, transposing a tensor is equivalent to swapping a pair of axes.
      Parameters:
      src - Entries of the tensor.
      shape - Shape of the tensor to transpose.
      axis1 - First axis to swap in transpose.
      axis2 - Second axis to swap in transpose.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
    • standardConcurrent

      public static <T> Object[] standardConcurrent(Object[] src, Shape shape, int axis1, int axis2, Object[] dest)
      Transposes tensor along specified axes using a standard concurrent transpose algorithm. In this context, transposing a tensor is equivalent to swapping a pair of axes.
      Parameters:
      src - Entries of the tensor.
      shape - Shape of the tensor to transpose.
      axis1 - First axis to swap in transpose.
      axis2 - Second axis to swap in transpose.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
    • standard

      public static <T> Object[] standard(Object[] src, Shape shape, int[] axes, Object[] dest)
      Computes the transpose of a tensor. That is, interchanges the axes of the tensor so that it matches the specified axes permutation.
      Parameters:
      src - Entries of the tensor.
      shape - Shape of the tensor to transpose.
      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}.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
      Throws:
      IllegalArgumentException - If the axes array is not a permutation of {0, 1, 2, ..., N-1}.
      IllegalArgumentException - If the shape rank is less than 2.
    • standard

      public static double[] standard(double[] src, Shape shape, int[] axes, double[] dest)
      Computes the transpose of a tensor. That is, interchanges the axes of the tensor so that it matches the specified axes permutation.
      Parameters:
      src - Entries of the tensor.
      shape - Shape of the tensor to transpose.
      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}.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
      Throws:
      IllegalArgumentException - If the axes array is not a permutation of {0, 1, 2, ..., N-1}.
      IllegalArgumentException - If the shape rank is less than 2.
    • standardConcurrent

      public static <T> Object[] standardConcurrent(Object[] src, Shape shape, int[] axes, Object[] dest)
      Computes the transpose of a tensor using a concurrent implementation. That is, interchanges the axes of the tensor so that it matches the specified axes permutation.
      Parameters:
      src - Entries of the tensor.
      shape - Shape of the tensor to transpose.
      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}.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
      Throws:
      IllegalArgumentException - If the axes array is not a permutation of {0, 1, 2, ..., N-1}.
      IllegalArgumentException - If the shape rank is less than 2.
    • standardMatrix

      public static <T> Object[] standardMatrix(Object[] src, int numRows, int numCols, Object[] dest)
      Transposes a matrix using the standard algorithm.
      Parameters:
      src - Entries of the matrix to transpose.
      numRows - Number of rows in the matrix.
      numCols - Number of columns in the matrix.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
    • blockedMatrix

      public static Object[] blockedMatrix(Object[] src, int numRows, int numCols, Object[] dest)
      Transposes a matrix using a blocked algorithm. To get or set the block size see Configurations.getBlockSize() or Configurations.setBlockSize(int).
      Parameters:
      src - Source matrix in the transpose.
      numRows - Number of rows in the matrix.
      numCols - Number of columns in the matrix.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
    • standardMatrixConcurrent

      public static Object[] standardMatrixConcurrent(Object[] src, int numRows, int numCols, Object[] dest)
      Computes the transpose of a matrix using a standard concurrent algorithm.
      Parameters:
      src - Entries of the matrix to transpose.
      numRows - Number of rows in source matrix.
      numCols - Number of columns in source matrix.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.
    • blockedMatrixConcurrent

      public static Object[] blockedMatrixConcurrent(Object[] src, int numRows, int numCols, Object[] dest)
      Computes the transpose of a matrix using a blocked concurrent algorithm.
      Parameters:
      src - Entries of the matrix to transpose.
      numRows - Number of rows in source matrix.
      numCols - Number of columns in source matrix.
      dest - Array to store the transpose result in. May be null. If not null, must satisfy: dest.length >= src.length.
      Returns:
      If dest != null, a reference to dest is returned. If dest == null then a new array of appropriate size will be constructed and returned.