Class DenseTranspose
java.lang.Object
org.flag4j.linalg.ops.dense.DenseTranspose
This utility class provides methods for computing the transpose of a dense tensor.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]blockedMatrix(Object[] src, int numRows, int numCols, Object[] dest) Transposes a matrix using a blocked algorithm.static Object[]blockedMatrixConcurrent(Object[] src, int numRows, int numCols, Object[] dest) Computes the transpose of a matrix using a blocked concurrent algorithm.static double[]Computes the transpose of a tensor.static <T> Object[]Computes the transpose of a tensor.static Object[]Transposes tensor along specified axes using a standard transpose algorithm.static <T> Object[]standardConcurrent(Object[] src, Shape shape, int[] axes, Object[] dest) Computes the transpose of a tensor using a concurrent implementation.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.static <T> Object[]standardMatrix(Object[] src, int numRows, int numCols, Object[] dest) Transposes a matrix using the standard algorithm.static Object[]standardMatrixConcurrent(Object[] src, int numRows, int numCols, Object[] dest) Computes the transpose of a matrix using a standard concurrent algorithm.
-
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.dest- Array to store the transpose result in. May benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen 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 benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned.
-
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 lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.dest- Array to store the transpose result in. May benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned. - Throws:
IllegalArgumentException- If theaxesarray is not a permutation of{0, 1, 2, ..., N-1}.IllegalArgumentException- If theshaperank is less than 2.
-
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 lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.dest- Array to store the transpose result in. May benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned. - Throws:
IllegalArgumentException- If theaxesarray is not a permutation of{0, 1, 2, ..., N-1}.IllegalArgumentException- If theshaperank 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 lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.dest- Array to store the transpose result in. May benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned. - Throws:
IllegalArgumentException- If theaxesarray is not a permutation of{0, 1, 2, ..., N-1}.IllegalArgumentException- If theshaperank is less than 2.
-
standardMatrix
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 benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned.
-
blockedMatrix
Transposes a matrix using a blocked algorithm. To get or set the block size seeConfigurations.getBlockSize()orConfigurations.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 benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen 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 benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen 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 benull. If not null, must satisfy:dest.length >= src.length.- Returns:
- If
dest != null, a reference todestis returned. Ifdest == nullthen a new array of appropriate size will be constructed and returned.
-