MathArrays { public static void checkRectangular(final long[][] in) throws NullArgumentException, DimensionMismatchException { MathUtils.checkNotNull(in); for (int i = 1; i < in.length; i++) { if (in[i].length != in[0].length) { throw new DimensionMismatchException( LocalizedFormats.DIFFERENT_ROWS_LENGTHS, in[i].length, in[0].length); } } } private  MathArrays(); static double[] scale(double val, final double[] arr); static void scaleInPlace(double val, final double[] arr); static double[] ebeAdd(double[] a, double[] b); static double[] ebeSubtract(double[] a, double[] b); static double[] ebeMultiply(double[] a, double[] b); static double[] ebeDivide(double[] a, double[] b); static double distance1(double[] p1, double[] p2); static int distance1(int[] p1, int[] p2); static double distance(double[] p1, double[] p2); static double distance(int[] p1, int[] p2); static double distanceInf(double[] p1, double[] p2); static int distanceInf(int[] p1, int[] p2); static boolean isMonotonic(T[] val,
                                      OrderDirection dir,
                                      boolean strict); static boolean isMonotonic(double[] val, OrderDirection dir, boolean strict); static boolean checkOrder(double[] val, OrderDirection dir,
                                     boolean strict, boolean abort); static void checkOrder(double[] val, OrderDirection dir,
                                  boolean strict); static void checkOrder(double[] val); static void checkRectangular(final long[][] in); static void checkPositive(final double[] in); static void checkNotNaN(final double[] in); static void checkNonNegative(final long[] in); static void checkNonNegative(final long[][] in); static double safeNorm(double[] v); static void sortInPlace(double[] x, double[] ... yList); static void sortInPlace(double[] x,
                                   final OrderDirection dir,
                                   double[] ... yList); static int[] copyOf(int[] source); static double[] copyOf(double[] source); static int[] copyOf(int[] source, int len); static double[] copyOf(double[] source, int len); static double[] copyOfRange(double[] source, int from, int to); static double linearCombination(final double[] a, final double[] b); static double linearCombination(final double a1, final double b1,
                                           final double a2, final double b2); static double linearCombination(final double a1, final double b1,
                                           final double a2, final double b2,
                                           final double a3, final double b3); static double linearCombination(final double a1, final double b1,
                                           final double a2, final double b2,
                                           final double a3, final double b3,
                                           final double a4, final double b4); static boolean equals(float[] x, float[] y); static boolean equalsIncludingNaN(float[] x, float[] y); static boolean equals(double[] x, double[] y); static boolean equalsIncludingNaN(double[] x, double[] y); static double[] normalizeArray(double[] values, double normalizedSum); static T[] buildArray(final Field<T> field, final int length); @SuppressWarnings("unchecked") static T[][] buildArray(final Field<T> field, final int rows, final int columns); static double[] convolve(double[] x, double[] h); static void shuffle(int[] list,
                               int start,
                               Position pos); static void shuffle(int[] list,
                               int start,
                               Position pos,
                               RandomGenerator rng); static void shuffle(int[] list,
                               RandomGenerator rng); static void shuffle(int[] list); static int[] natural(int n); static int[] sequence(int size,
                                 int start,
                                 int stride); static boolean verifyValues(final double[] values, final int begin, final int length); static boolean verifyValues(final double[] values, final int begin,
            final int length, final boolean allowEmpty); static boolean verifyValues(
        final double[] values,
        final double[] weights,
        final int begin,
        final int length); static boolean verifyValues(final double[] values, final double[] weights,
            final int begin, final int length, final boolean allowEmpty);  }
@Test public void testCheckRectangular() { final long[][] rect = new long[][] {{0, 1}, {2, 3}}; final long[][] ragged = new long[][] {{0, 1}, {2}}; final long[][] nullArray = null; final long[][] empty = new long[][] {}; MathArrays.checkRectangular(rect); MathArrays.checkRectangular(empty); try { MathArrays.checkRectangular(ragged); Assert.fail("Expecting DimensionMismatchException"); } catch (DimensionMismatchException ex) { } try { MathArrays.checkRectangular(nullArray); Assert.fail("Expecting NullArgumentException"); } catch (NullArgumentException ex) { } }