Example usage for org.apache.commons.math3.exception DimensionMismatchException DimensionMismatchException

List of usage examples for org.apache.commons.math3.exception DimensionMismatchException DimensionMismatchException

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception DimensionMismatchException DimensionMismatchException.

Prototype

public DimensionMismatchException(Localizable specific, int wrong, int expected) 

Source Link

Document

Construct an exception from the mismatched dimensions.

Usage

From source file:logic.ApachePolyNewtonForm.java

/**
 * Verifies that the input arrays are valid.
 * <p>//www.ja  va  2 s.  c  om
 * The centers must be distinct for interpolation purposes, but not
 * for general use. Thus it is not verified here.</p>
 *
 * @param a the coefficients in Newton form formula
 * @param c the centers
 * @throws NullArgumentException if any argument is {@code null}.
 * @throws NoDataException if any array has zero length.
 * @throws DimensionMismatchException if the size difference between
 * {@code a} and {@code c} is not equal to 1.
 * @see org.apache.commons.math3.analysis.interpolation.DividedDifferenceInterpolator#computeDividedDifference(double[],
 * double[])
 */
protected static void verifyInputArray(double a[], double c[])
        throws NullArgumentException, NoDataException, DimensionMismatchException {
    MathUtils.checkNotNull(a);
    MathUtils.checkNotNull(c);
    if (a.length == 0 || c.length == 0) {
        throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
    }
    if (a.length != c.length + 1) {
        throw new DimensionMismatchException(LocalizedFormats.ARRAY_SIZES_SHOULD_HAVE_DIFFERENCE_1, a.length,
                c.length);
    }
}

From source file:nova.core.util.math.MatrixUtil.java

public static RealMatrix augment(RealMatrix matrix, int rows, int columns) {
    if (matrix.getRowDimension() > rows)
        throw new DimensionMismatchException(of("rows: {0} !< {1}"), matrix.getRowDimension(), rows);
    if (matrix.getColumnDimension() > columns)
        throw new DimensionMismatchException(of("columns: {0} !< {1}"), matrix.getColumnDimension(), columns);

    RealMatrix augmented = MatrixUtils.createRealMatrix(rows, columns);
    augmented.setSubMatrix(matrix.getData(), 0, 0);
    return augmented;
}

From source file:org.gitools.analysis.groupcomparison.format.math33Preview.MathArrays.java

/**
 * Throws DimensionMismatchException if the input array is not rectangular.
 *
 * @param in array to be tested/*from   w  w w. j a  v a2 s . c  o m*/
 * @throws NullArgumentException      if input array is null
 * @throws DimensionMismatchException if input array is not rectangular
 * @since 3.1
 */
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);
        }
    }
}