Package org.flag4j.operations.dense.real
Class RealDenseTranspose
java.lang.Object
org.flag4j.operations.dense.real.RealDenseTranspose
This class contains several low-level algorithms for computing the transpose of real dense tensors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[][]
blockedIntMatrix
(int[][] src) Transposes an integer matrix using a blocked algorithm.static double[]
blockedMatrix
(double[] src, int numRows, int numCols) Transposes a matrix using a blocked algorithm.static double[]
blockedMatrixConcurrent
(double[] src, int numRows, int numCols) Computes the transpose of a matrix using a blocked concurrent algorithm.static double[]
Computes the transpose of a tensor.static double[]
Transposes tensor along specified axes using a standard transpose algorithm.static double[]
standardConcurrent
(double[] src, Shape shape, int[] axes) Computes the transpose of a tensor using a concurrent implementation.static double[]
standardConcurrent
(double[] src, Shape shape, int axis1, int axis2) Transposes tensor along specified axes using a standard concurrent transpose algorithm.static int[][]
standardIntMatrix
(int[][] src) Transposes a matrix using the standard algorithm.static double[]
standardMatrix
(double[] src, int numRows, int numCols) Transposes a matrix using the standard algorithm.static double[]
standardMatrixConcurrent
(double[] src, int numRows, int numCols) Computes the transpose of a matrix using a standard concurrent algorithm.
-
Constructor Details
-
RealDenseTranspose
private RealDenseTranspose()
-
-
Method Details
-
standard
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.- Returns:
- The transpose of the tensor along the specified axes.
-
standard
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 rankN
, then this must be an array of lengthN
which is a permutation of{0, 1, 2, ..., N-1}
.- Returns:
- The transpose of the tensor along the specified axes.
- Throws:
IllegalArgumentException
- If theaxes
array is not a permutation of{0, 1, 2, ..., N-1}
.IllegalArgumentException
- If theshape
rank is less than 2.
-
standardConcurrent
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 rankN
, then this must be an array of lengthN
which is a permutation of{0, 1, 2, ..., N-1}
.- Returns:
- The transpose of the tensor along the specified axes.
- Throws:
IllegalArgumentException
- If theaxes
array is not a permutation of{0, 1, 2, ..., N-1}
.IllegalArgumentException
- If theshape
rank is less than 2.
-
standardConcurrent
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.- Returns:
- The transpose of the tensor along the specified axes.
-
standardMatrix
public static double[] standardMatrix(double[] src, int numRows, int numCols) 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.- Returns:
- The transpose of the matrix.
-
blockedMatrix
public static double[] blockedMatrix(double[] src, int numRows, int numCols) Transposes a matrix using a blocked algorithm. To get or set the block size seeConfigurations.getBlockSize()
orConfigurations.setBlockSize(int)
.- Parameters:
src
- Source entries to compute transpose of.numRows
- Number of rows in the matrix.numCols
- Number of columns in the matrix.- Returns:
- The transpose of this tensor along specified axes
-
standardMatrixConcurrent
public static double[] standardMatrixConcurrent(double[] src, int numRows, int numCols) 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.- Returns:
- The transpose of the source matrix.
-
blockedMatrixConcurrent
public static double[] blockedMatrixConcurrent(double[] src, int numRows, int numCols) 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.- Returns:
- The transpose of the source matrix.
-
standardIntMatrix
public static int[][] standardIntMatrix(int[][] src) Transposes a matrix using the standard algorithm.- Parameters:
src
- Entries of the matrix to transpose.- Returns:
- The transpose of the matrix.
-
blockedIntMatrix
public static int[][] blockedIntMatrix(int[][] src) Transposes an integer matrix using a blocked algorithm.- Parameters:
src
- Entries of the matrix to transpose.- Returns:
- The transpose of the matrix.
-