Class CooTranspose
java.lang.Object
org.flag4j.linalg.ops.sparse.coo.CooTranspose
Utility class for computing the transpose of a sparse COO tensor or matrix.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
tensorTranspose
(Shape shape, Object[] srcEntries, int[][] srcIndices, int[] axes, Object[] destEntries, int[][] destIndices) Computes the transpose of a sparse COO tensor.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 exchangingaxis1
andaxis2
.
-
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
andaxis2
.- 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 assrcEntries
.destIndices
- Array to store the non-zero indices of the transpose. Must have shape[srcEntries.length][shape.getRank()]
srcIndices
-- Throws:
IndexOutOfBoundsException
- If eitheraxis1
oraxis2
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 byaxes
.- 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 rankN
, then this must be an array of lengthN
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 assrcEntries
.destIndices
- Array to store the non-zero indices of the transpose. Must have shape[srcEntries.length][shape.getRank()]
- Throws:
IllegalArgumentException
- IfsrcEntries
,srcIndices
,destEntries
, anddestIndices
do not all have the same length.IndexOutOfBoundsException
- If any element ofaxes
is out of bounds for the rank of this tensor.IllegalArgumentException
- Ifaxes
is not a permutation of{1, 2, 3, ... N-1}
.
-