Class TransposeDispatcher

java.lang.Object
org.flag4j.linalg.ops.TransposeDispatcher

public final class TransposeDispatcher extends Object
Provides a dispatch method for dynamically choosing the best matrix transpose algorithm.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    dispatch(double[] src, Shape shape)
    Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
    static Object[]
    dispatch(Object[] src, Shape shape, Object[] dest)
    Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
    static Matrix
    Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
    static <T extends Ring<T>>
    void
    dispatchHermitian(T[] src, Shape shape, T[] dest)
    Dispatches a matrix Hermitian transpose (i.e. conjugate transpose) problem to the appropriate algorithm based on its shape and size.
    static double[]
    dispatchTensor(double[] src, Shape shape, int[] axes)
    Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
    static Object[]
    dispatchTensor(Object[] src, Shape shape, int[] axes, Object[] dest)
    Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
    static <V extends Semiring<V>>
    AbstractDenseSemiringTensor<?,V>
    Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
    static <T> T[]
    dispatchTensor(T[] src, Shape srcShape, int axis1, int axis2, T[] dest)
    Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
    static <T extends AbstractDoubleTensor<T>>
    T
    dispatchTensor(T src, int axis1, int axis2)
    Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
    static <V extends Ring<V>>
    void
    dispatchTensorHermitian(Shape shape, V[] src, int[] axes, V[] dest)
    Dispatches a tensor Hermitian transpose problem to the appropriate algorithm based on its shape and size.
    static <V extends Ring<V>>
    void
    dispatchTensorHermitian(Shape shape, V[] src, int axis1, int axis2, V[] dest)
    Dispatches a tensor Hermitian transpose problem to the appropriate algorithm based on its shape and size.

    Methods inherited from class java.lang.Object

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

    • dispatch

      public static Matrix dispatch(Matrix src)
      Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Matrix to transpose.
      Returns:
      The transpose of the source matrix.
    • dispatch

      public static double[] dispatch(double[] src, Shape shape)
      Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Matrix to transpose.
      Returns:
      The transpose of the source matrix.
    • dispatch

      public static Object[] dispatch(Object[] src, Shape shape, Object[] dest)
      Dispatches a matrix transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Matrix to transpose.
      shape - Shape of the matrix to transpose.
      dest - Array to store the transpose result in. May be null. If not null, must be at least as large as src.
      Returns:
      If dest != null a reference to the dest array will be returned. Otherwise, if dest == null then a new array will be created and returned.
    • dispatchHermitian

      public static <T extends Ring<T>> void dispatchHermitian(T[] src, Shape shape, T[] dest)
      Dispatches a matrix Hermitian transpose (i.e. conjugate transpose) problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Entries of the matrix to transpose and conjugate.
      shape - Shape of the matrix to transpose and conjugate.
      dest - Array to store the Hermitian transpose result in. May be null. If not null, must be at least as large as src.
    • dispatchTensor

      public static <T extends AbstractDoubleTensor<T>> T dispatchTensor(T src, int axis1, int axis2)
      Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Tensor to transpose.
      axis1 - First axis in tensor transpose.
      axis2 - Second axis in tensor transpose.
      Returns:
      The result of the tensor transpose.
      Throws:
      ArrayIndexOutOfBoundsException - If either axis is not within the src tensor.
    • dispatchTensor

      public static double[] dispatchTensor(double[] src, Shape shape, int[] axes)
      Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Tensor to transpose.
      axes - Permutation of axes in the tensor transpose.
      Returns:
      The result of the tensor transpose.
      Throws:
      ArrayIndexOutOfBoundsException - If either axis is not within the src tensor.
    • dispatchTensor

      public static <T> T[] dispatchTensor(T[] src, Shape srcShape, int axis1, int axis2, T[] dest)
      Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Entries of the tensor to transpose.
      srcShape - Shape of the tensor to transpose.
      axis1 - First axis in tensor transpose.
      axis2 - Second axis in tensor transpose.
      dest - Array to store the transpose result in. May be null. Must at least as large as src.
      Returns:
      If dest != null a reference to the dest tensor. Otherwise, if dest == null a new array will be constructed and returned.
      Throws:
      IndexOutOfBoundsException - If dest.length < src.length.
    • dispatchTensor

      public static <V extends Semiring<V>> AbstractDenseSemiringTensor<?,V> dispatchTensor(AbstractDenseSemiringTensor<?,V> src, int[] axes)
      Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Entries of tensor to transpose.
      axes - Permutation of axes in the tensor transpose.
      Returns:
      The result of the tensor transpose.
      Throws:
      ArrayIndexOutOfBoundsException - If either axis is not within the src tensor.
    • dispatchTensor

      public static Object[] dispatchTensor(Object[] src, Shape shape, int[] axes, Object[] dest)
      Dispatches a tensor transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Entries of tensor to transpose.
      shape - Shape fo the tensor to transpose.
      axes - Permutation of axes in the tensor transpose.
      dest - Array to store the transpose result in. May be null. If dest != null, both of the following must be satisfied:
      • dest.length >= src.length
      • dest != src
      Returns:
      The result of the tensor transpose.
      Throws:
      ArrayIndexOutOfBoundsException - If either axis is not within the src tensor or if dest.length < src.length.
      IllegalArgumentException - If src == dest.
    • dispatchTensorHermitian

      public static <V extends Ring<V>> void dispatchTensorHermitian(Shape shape, V[] src, int axis1, int axis2, V[] dest)
      Dispatches a tensor Hermitian transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      shape - Shape of the tensor to transpose.
      src - Entries of the tensor to transpose.
      axis1 - First axis in tensor transpose.
      axis2 - Second axis in tensor transpose.
      dest - Array to store the transpose result in.
    • dispatchTensorHermitian

      public static <V extends Ring<V>> void dispatchTensorHermitian(Shape shape, V[] src, int[] axes, V[] dest)
      Dispatches a tensor Hermitian transpose problem to the appropriate algorithm based on its shape and size.
      Parameters:
      src - Entries of tensor to transpose.
      axes - Permutation of axes in the tensor transpose.
      dest - Array to store the result of the tensor transpose in.
      Shape - shape of the tensor to transpose.
      Throws:
      ArrayIndexOutOfBoundsException - If either axis is not within the src tensor.