Class 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 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)
      • checkDTypeCompatibility

        public static void checkDTypeCompatibility​(NDArray<?> me,
                                                   Object array)
      • 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)
      • getDType

        public static Class<?> getDType​(Object array)
      • getEndCartesianIndex

        public static int[] getEndCartesianIndex​(int[] shape)