Package io.github.hakkelt.ndarrays
Class NDArrayUtils
- java.lang.Object
-
- io.github.hakkelt.ndarrays.NDArrayUtils
-
public class NDArrayUtils extends Object
Utility class to help conversion between linear indexing and Cartesian indexing, and ease checks against "out of bounds" and "incompatible shape" errors.
-
-
Field Summary
Fields Modifier and Type Field Description static int
PARALLEL_STREAM_THRESHOLD
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
boundaryCheck(int[] indices, int[] shape)
static void
boundaryCheck(int linearIndex, int length)
static int
calculateLength(int[] shape)
static int[]
calculateMultipliers(int[] shape)
static int
cartesianIndicesToLinearIndex(int[] indices, int[] multipliers)
static void
checkDTypeCompatibility(NDArray<?> me, Object array)
static void
checkShapeCompatibility(NDArray<?> me, int[] arrayDims)
static int[]
computeDims(Object[] input)
static Class<?>
getDType(Object array)
static int[]
getEndCartesianIndex(int[] shape)
static int[]
linearIndexToCartesianIndices(int linearIndex, int[] multipliers)
static int[]
unwrap(int[] indices, int[] shape)
static int
unwrap(int linearIndex, int length)
-
-
-
Field Detail
-
PARALLEL_STREAM_THRESHOLD
public static final int PARALLEL_STREAM_THRESHOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkShapeCompatibility
public static void checkShapeCompatibility(NDArray<?> me, int[] arrayDims)
-
calculateLength
public static int calculateLength(int[] shape)
-
calculateMultipliers
public static int[] calculateMultipliers(int[] shape)
-
cartesianIndicesToLinearIndex
public static int cartesianIndicesToLinearIndex(int[] indices, int[] multipliers)
-
linearIndexToCartesianIndices
public static int[] linearIndexToCartesianIndices(int linearIndex, int[] multipliers)
-
boundaryCheck
public static void boundaryCheck(int[] indices, int[] shape)
-
unwrap
public static int[] unwrap(int[] indices, int[] shape)
-
unwrap
public static int unwrap(int linearIndex, int length)
-
boundaryCheck
public static void boundaryCheck(int linearIndex, int length)
-
computeDims
public static int[] computeDims(Object[] input)
-
getEndCartesianIndex
public static int[] getEndCartesianIndex(int[] shape)
-
-