/** * Modify the denominator format. * @param format the new denominator format value. * @throws NullArgumentException if {@code format} is {@code null}. */ public void setDenominatorFormat(final NumberFormat format) { if (format == null) { throw new NullArgumentException(LocalizedFormats.DENOMINATOR_FORMAT); } this.denominatorFormat = format; }
/** * Modify the whole format. * @param format The new whole format value. * @throws NullArgumentException if {@code format} is {@code null}. */ public void setWholeFormat(final NumberFormat format) { if (format == null) { throw new NullArgumentException(LocalizedFormats.WHOLE_FORMAT); } this.wholeFormat = format; } }
/** * Modify the numerator format. * @param format the new numerator format value. * @throws NullArgumentException if {@code format} is {@code null}. */ public void setNumeratorFormat(final NumberFormat format) { if (format == null) { throw new NullArgumentException(LocalizedFormats.NUMERATOR_FORMAT); } this.numeratorFormat = format; }
/** * Modify the whole format. * @param format The new whole format value. * @throws NullArgumentException if {@code format} is {@code null}. */ public void setWholeFormat(NumberFormat format) { if (format == null) { throw new NullArgumentException(LocalizedFormats.WHOLE_FORMAT); } this.wholeFormat = format; } }
/** * Checks that an object is not null. * * @param o Object to be checked. * @throws NullArgumentException if {@code o} is {@code null}. */ public static void checkNotNull(Object o) throws NullArgumentException { if (o == null) { throw new NullArgumentException(); } } }
/** * Create an instance with a custom number format for both real and * imaginary parts. * @param format the custom format for both real and imaginary parts. * @throws NullArgumentException if {@code realFormat} is {@code null}. */ public ComplexFormat(NumberFormat format) throws NullArgumentException { if (format == null) { throw new NullArgumentException(LocalizedFormats.IMAGINARY_FORMAT); } this.imaginaryCharacter = DEFAULT_IMAGINARY_CHARACTER; this.imaginaryFormat = format; this.realFormat = format; }
/** * Checks that an object is not null. * * @param o Object to be checked. * @param pattern Message pattern. * @param args Arguments to replace the placeholders in {@code pattern}. * @throws NullArgumentException if {@code o} is {@code null}. */ public static void checkNotNull(Object o, Localizable pattern, Object ... args) throws NullArgumentException { if (o == null) { throw new NullArgumentException(pattern, args); } }
/** * Defines a maximal count and a callback method to be triggered at * counter exhaustion. * * @param max Maximal count. * @param cb Function to be called when the maximal count has been reached. * @throws NullArgumentException if {@code cb} is {@code null} */ public Incrementor(int max, MaxCountExceededCallback cb) throws NullArgumentException { if (cb == null){ throw new NullArgumentException(); } maximalCount = max; maxCountCallback = cb; }
/** * Create an instance with a custom number format for the real part and a * custom number format for the imaginary part. * @param realFormat the custom format for the real part. * @param imaginaryFormat the custom format for the imaginary part. * @throws NullArgumentException if {@code imaginaryFormat} is {@code null}. * @throws NullArgumentException if {@code realFormat} is {@code null}. */ public ComplexFormat(NumberFormat realFormat, NumberFormat imaginaryFormat) throws NullArgumentException { if (imaginaryFormat == null) { throw new NullArgumentException(LocalizedFormats.IMAGINARY_FORMAT); } if (realFormat == null) { throw new NullArgumentException(LocalizedFormats.REAL_FORMAT); } this.imaginaryCharacter = DEFAULT_IMAGINARY_CHARACTER; this.imaginaryFormat = imaginaryFormat; this.realFormat = realFormat; }
/** * Creates a {@link RealVector} using the data from the input array. * * @param data the input data * @return a data.length RealVector * @throws NoDataException if {@code data} is empty. * @throws NullArgumentException if {@code data} is {@code null}. */ public static RealVector createRealVector(double[] data) throws NoDataException, NullArgumentException { if (data == null) { throw new NullArgumentException(); } return new ArrayRealVector(data, true); }
/** * Verifies that {@code array} has length at least 2. * * @param array array to test * @throws NullArgumentException if array is null * @throws InsufficientDataException if array is too short */ private void checkArray(double[] array) { if (array == null) { throw new NullArgumentException(LocalizedFormats.NULL_NOT_ALLOWED); } if (array.length < 2) { throw new InsufficientDataException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, array.length, 2); } }
/** * This default implementation just calls {@link #increment} in a loop over * the input array. * <p> * Throws IllegalArgumentException if the input values array is null.</p> * * @param values values to add * @throws MathIllegalArgumentException if values is null * @see org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[]) */ public void incrementAll(double[] values) throws MathIllegalArgumentException { if (values == null) { throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY); } incrementAll(values, 0, values.length); }
/** * Ensures that the provided arrays fulfills the assumptions. * * @param x first sample * @param y second sample * @throws NullArgumentException if {@code x} or {@code y} are {@code null}. * @throws NoDataException if {@code x} or {@code y} are zero-length. */ private void ensureDataConformance(final double[] x, final double[] y) throws NullArgumentException, NoDataException { if (x == null || y == null) { throw new NullArgumentException(); } if (x.length == 0 || y.length == 0) { throw new NoDataException(); } }
/** * <p> * Multiplies the value of this fraction by the passed * <code>BigInteger</code>, returning the result in reduced form. * </p> * * @param bg the {@code BigInteger} to multiply by. * @return a {@code BigFraction} instance with the resulting values. * @throws NullArgumentException if {@code bg} is {@code null}. */ public BigFraction multiply(final BigInteger bg) { if (bg == null) { throw new NullArgumentException(); } if (numerator.signum() == 0 || bg.signum() == 0) { return ZERO; } return new BigFraction(bg.multiply(numerator), denominator); }
/** * Construct a vector from another vector, using a deep copy. * * @param v vector to copy. * @throws NullArgumentException if {@code v} is {@code null}. */ public ArrayRealVector(RealVector v) throws NullArgumentException { if (v == null) { throw new NullArgumentException(); } data = new double[v.getDimension()]; for (int i = 0; i < data.length; ++i) { data[i] = v.getEntry(i); } }
/** * Loads new y sample data, overriding any previous data. * * @param y the array representing the y sample * @throws NullArgumentException if y is null * @throws NoDataException if y is empty */ protected void newYSampleData(double[] y) { if (y == null) { throw new NullArgumentException(); } if (y.length == 0) { throw new NoDataException(); } this.yVector = new ArrayRealVector(y); }
/** * Create a row {@link RealMatrix} using the data from the input * array. * * @param rowData the input row data * @return a 1 x rowData.length RealMatrix * @throws NoDataException if {@code rowData} is empty. * @throws NullArgumentException if {@code rowData} is {@code null}. */ public static RealMatrix createRowRealMatrix(double[] rowData) throws NoDataException, NullArgumentException { if (rowData == null) { throw new NullArgumentException(); } final int nCols = rowData.length; final RealMatrix m = createRealMatrix(1, nCols); for (int i = 0; i < nCols; ++i) { m.setEntry(0, i, rowData[i]); } return m; }
/** * @throws MathUnsupportedOperationException if bounds were passed to the * {@link #optimize(OptimizationData[]) optimize} method. * @throws NullArgumentException if no initial simplex was passed to the * {@link #optimize(OptimizationData[]) optimize} method. */ private void checkParameters() { if (simplex == null) { throw new NullArgumentException(); } if (getLowerBound() != null || getUpperBound() != null) { throw new MathUnsupportedOperationException(LocalizedFormats.CONSTRAINT); } } }
/** * Create a PearsonsCorrelation from a {@link Covariance}. The correlation * matrix is computed by scaling the Covariance's covariance matrix. * The Covariance instance must have been created from a data matrix with * columns representing variable values. * * @param covariance Covariance instance */ public PearsonsCorrelation(Covariance covariance) { RealMatrix covarianceMatrix = covariance.getCovarianceMatrix(); if (covarianceMatrix == null) { throw new NullArgumentException(LocalizedFormats.COVARIANCE_MATRIX); } nObs = covariance.getN(); correlationMatrix = covarianceToCorrelation(covarianceMatrix); }
/** * Check sample data. * * @param stat Statistical summary. * @throws NullArgumentException if {@code data} is {@code null}. * @throws NumberIsTooSmallException if there is not enough sample data. */ private void checkSampleData(final StatisticalSummary stat) throws NullArgumentException, NumberIsTooSmallException { if (stat == null) { throw new NullArgumentException(); } if (stat.getN() < 2) { throw new NumberIsTooSmallException( LocalizedFormats.INSUFFICIENT_DATA_FOR_T_STATISTIC, stat.getN(), 2, true); } }