FunctionUtils { public static int[] fromTensorIndex(final int index, final int[] dimensions) { Validate.notNull(dimensions, "dimensions"); final int dim = dimensions.length; final int[] res = new int[dim]; int product = 1; final int[] products = new int[dim - 1]; for (int i = 0; i < dim - 1; i++) { product *= dimensions[i]; products[i] = product; } int a = index; for (int i = dim - 1; i > 0; i--) { res[i] = a / products[i - 1]; a -= res[i] * products[i - 1]; } res[0] = a; return res; } private  FunctionUtils(); static double square(final double x); static double cube(final double x); static int toTensorIndex(final int[] indices, final int[] dimensions); static int[] fromTensorIndex(final int index, final int[] dimensions); static double[] unique(final double[] in); static int[] unique(final int[] in); static int getLowerBoundIndex(final double[] set, final double value);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDimensions2() { FunctionUtils.fromTensorIndex(2, null); }