computeRule(int numberOfPoints)
- throws NotStrictlyPositiveException {
- if (numberOfPoints <= 0) {
- throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
- numberOfPoints);
- }
+ throws DimensionMismatchException {
if (numberOfPoints == 1) {
// Break recursion.
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java
index 0b5be8842..9465c2cdc 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java
@@ -21,6 +21,7 @@ import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
import org.apache.commons.math3.exception.NonMonotonicSequenceException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.util.MathArrays;
/**
@@ -37,9 +38,8 @@ public class BicubicSplineInterpolator
public BicubicSplineInterpolatingFunction interpolate(final double[] xval,
final double[] yval,
final double[][] fval)
- throws NoDataException,
- DimensionMismatchException,
- NonMonotonicSequenceException {
+ throws NoDataException, DimensionMismatchException,
+ NonMonotonicSequenceException, NumberIsTooSmallException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw new NoDataException();
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java
index 318aed8b8..0ba1b90d5 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.analysis.BivariateFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
/**
* Interface representing a bivariate real interpolating function where the
@@ -39,9 +41,12 @@ public interface BivariateGridInterpolator {
* @return a function which interpolates the dataset.
* @throws NoDataException if any of the arrays has zero length.
* @throws DimensionMismatchException if the array lengths are inconsistent.
+ * @throws NonMonotonicSequenceException if the array is not sorted.
+ * @throws NumberIsTooSmallException if the number of points is too small for
+ * the order of the interpolation
*/
BivariateFunction interpolate(double[] xval, double[] yval,
double[][] fval)
- throws NoDataException,
- DimensionMismatchException;
+ throws NoDataException, DimensionMismatchException,
+ NonMonotonicSequenceException, NumberIsTooSmallException;
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java
index ed8dc30b6..14199eb14 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java
@@ -20,11 +20,14 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.FieldElement;
+import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.MathArithmeticException;
import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.ZeroException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.MathArrays;
+import org.apache.commons.math3.util.MathUtils;
/** Polynomial interpolator using both sample values and sample derivatives.
*
@@ -82,10 +85,14 @@ public class FieldHermiteInterpolator> {
* and a previous point is zero (i.e. the two points are at same abscissa)
* @exception MathArithmeticException if the number of derivatives is larger
* than 20, which prevents computation of a factorial
+ * @throws DimensionMismatchException if derivative structures are inconsistent
+ * @throws NullArgumentException if x is null
*/
public void addSamplePoint(final T x, final T[] ... value)
- throws ZeroException, MathArithmeticException {
+ throws ZeroException, MathArithmeticException,
+ DimensionMismatchException, NullArgumentException {
+ MathUtils.checkNotNull(x);
T factorial = x.getField().getOne();
for (int i = 0; i < value.length; ++i) {
@@ -128,10 +135,12 @@ public class FieldHermiteInterpolator> {
* @param x interpolation abscissa
* @return interpolated value
* @exception NoDataException if sample is empty
+ * @throws NullArgumentException if x is null
*/
- public T[] value(T x) throws NoDataException {
+ public T[] value(T x) throws NoDataException, NullArgumentException {
// safety check
+ MathUtils.checkNotNull(x);
if (abscissae.isEmpty()) {
throw new NoDataException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
}
@@ -157,10 +166,12 @@ public class FieldHermiteInterpolator> {
* @return interpolated value and derivatives (value in row 0,
* 1st derivative in row 1, ... nth derivative in row n)
* @exception NoDataException if sample is empty
+ * @throws NullArgumentException if x is null
*/
- public T[][] derivatives(T x, int order) throws NoDataException {
+ public T[][] derivatives(T x, int order) throws NoDataException, NullArgumentException {
// safety check
+ MathUtils.checkNotNull(x);
if (abscissae.isEmpty()) {
throw new NoDataException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java
index a8ee17697..2139e6800 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java
@@ -193,8 +193,9 @@ public class MicrosphereInterpolatingFunction
/**
* @param point Interpolation point.
* @return the interpolated value.
+ * @throws DimensionMismatchException if point dimension does not math sample
*/
- public double value(double[] point) {
+ public double value(double[] point) throws DimensionMismatchException {
final RealVector p = new ArrayRealVector(point);
// Reset.
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java
index 39239567f..04c6b0bdc 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java
@@ -17,6 +17,10 @@
package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.analysis.MultivariateFunction;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NullArgumentException;
/**
* Interface representing a univariate real interpolating function.
@@ -36,15 +40,13 @@ public interface MultivariateInterpolator {
* point (where {@code d} is thus the dimension of the space).
* @param yval the values for the interpolation points
* @return a function which interpolates the data set
- * @throws org.apache.commons.math3.exception.MathIllegalArgumentException
- * if the arguments violate assumptions made by the interpolation
- * algorithm.
- * @throws org.apache.commons.math3.exception.DimensionMismatchException
- * when the array dimensions are not consistent.
- * @throws org.apache.commons.math3.exception.NoDataException if an
- * array has zero-length.
- * @throws org.apache.commons.math3.exception.NullArgumentException if
- * the arguments are {@code null}.
+ * @throws MathIllegalArgumentException if the arguments violate assumptions
+ * made by the interpolation algorithm.
+ * @throws DimensionMismatchException when the array dimensions are not consistent.
+ * @throws NoDataException if an array has zero-length.
+ * @throws NullArgumentException if the arguments are {@code null}.
*/
- MultivariateFunction interpolate(double[][] xval, double[] yval);
+ MultivariateFunction interpolate(double[][] xval, double[] yval)
+ throws MathIllegalArgumentException, DimensionMismatchException,
+ NoDataException, NullArgumentException;
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
index 785cf1a83..0c62e897a 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
@@ -18,7 +18,9 @@ package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.exception.NotPositiveException;
+import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.util.MathArrays;
import org.apache.commons.math3.util.Precision;
import org.apache.commons.math3.optim.nonlinear.vector.jacobian.GaussNewtonOptimizer;
@@ -54,8 +56,10 @@ public class SmoothingPolynomialBicubicSplineInterpolator
/**
* @param degree Degree of the polynomial fitting functions.
+ * @exception NotPositiveException if degree is not positive
*/
- public SmoothingPolynomialBicubicSplineInterpolator(int degree) {
+ public SmoothingPolynomialBicubicSplineInterpolator(int degree)
+ throws NotPositiveException {
this(degree, degree);
}
@@ -64,9 +68,10 @@ public class SmoothingPolynomialBicubicSplineInterpolator
* x-dimension.
* @param yDegree Degree of the polynomial fitting functions along the
* y-dimension.
+ * @exception NotPositiveException if degrees are not positive
*/
- public SmoothingPolynomialBicubicSplineInterpolator(int xDegree,
- int yDegree) {
+ public SmoothingPolynomialBicubicSplineInterpolator(int xDegree, int yDegree)
+ throws NotPositiveException {
if (xDegree < 0) {
throw new NotPositiveException(xDegree);
}
@@ -91,8 +96,8 @@ public class SmoothingPolynomialBicubicSplineInterpolator
public BicubicSplineInterpolatingFunction interpolate(final double[] xval,
final double[] yval,
final double[][] fval)
- throws NoDataException,
- DimensionMismatchException {
+ throws NoDataException, NullArgumentException,
+ DimensionMismatchException, NonMonotonicSequenceException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw new NoDataException();
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java
index 386b0cf10..0fce8577a 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
import org.apache.commons.math3.exception.NonMonotonicSequenceException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.util.MathArrays;
/**
@@ -36,9 +37,8 @@ public class TricubicSplineInterpolator
final double[] yval,
final double[] zval,
final double[][][] fval)
- throws NoDataException,
- DimensionMismatchException,
- NonMonotonicSequenceException {
+ throws NoDataException, NumberIsTooSmallException,
+ DimensionMismatchException, NonMonotonicSequenceException {
if (xval.length == 0 || yval.length == 0 || zval.length == 0 || fval.length == 0) {
throw new NoDataException();
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java
index ec81fc722..bc040fc75 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.analysis.TrivariateFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
+import org.apache.commons.math3.exception.NumberIsTooSmallException;
/**
* Interface representing a trivariate real interpolating function where the
@@ -42,9 +44,12 @@ public interface TrivariateGridInterpolator {
* @return a function that interpolates the data set.
* @throws NoDataException if any of the arrays has zero length.
* @throws DimensionMismatchException if the array lengths are inconsistent.
+ * @throws NonMonotonicSequenceException if arrays are not sorted
+ * @throws NumberIsTooSmallException if the number of points is too small for
+ * the order of the interpolation
*/
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
double[][][] fval)
- throws NoDataException,
- DimensionMismatchException;
+ throws NoDataException, NumberIsTooSmallException,
+ DimensionMismatchException, NonMonotonicSequenceException;
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java
index e32acd64b..0edc98040 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java
@@ -17,6 +17,8 @@
package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
/**
* Interface representing a univariate real interpolating function.
@@ -30,9 +32,11 @@ public interface UnivariateInterpolator {
* @param xval Arguments for the interpolation points.
* @param yval Values for the interpolation points.
* @return a function which interpolates the dataset.
- * @throws org.apache.commons.math3.exception.MathIllegalArgumentException
+ * @throws MathIllegalArgumentException
* if the arguments violate assumptions made by the interpolation
* algorithm.
+ * @throws DimensionMismatchException if arrays lengthes do not match
*/
- UnivariateFunction interpolate(double xval[], double yval[]);
+ UnivariateFunction interpolate(double xval[], double yval[])
+ throws MathIllegalArgumentException, DimensionMismatchException;
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java b/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java
index 5fecb4cb8..585df2915 100644
--- a/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysis.interpolation;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.util.MathUtils;
import org.apache.commons.math3.util.MathArrays;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
/**
@@ -82,7 +84,7 @@ public class UnivariatePeriodicInterpolator
*/
public UnivariateFunction interpolate(double[] xval,
double[] yval)
- throws NumberIsTooSmallException {
+ throws NumberIsTooSmallException, NonMonotonicSequenceException {
if (xval.length < extend) {
throw new NumberIsTooSmallException(xval.length, extend, true);
}
@@ -114,7 +116,7 @@ public class UnivariatePeriodicInterpolator
final UnivariateFunction f = interpolator.interpolate(x, y);
return new UnivariateFunction() {
- public double value(final double x) {
+ public double value(final double x) throws MathIllegalArgumentException {
return f.value(MathUtils.reduce(x, period, offset));
}
};
diff --git a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java
index 2a5d079f2..f00799d9c 100644
--- a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java
+++ b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java
@@ -405,7 +405,8 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
}
/** {@inheritDoc} */
- public double value(final double x, final double ... parameters) {
+ public double value(final double x, final double ... parameters)
+ throws NoDataException {
return PolynomialFunction.evaluate(parameters, x);
}
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java
index aa05628a6..315c3ddf1 100644
--- a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java
+++ b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java
@@ -20,6 +20,7 @@ import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathArrays;
import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
@@ -65,10 +66,11 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
* @param y function values at interpolating points
* @throws DimensionMismatchException if the array lengths are different.
* @throws NumberIsTooSmallException if the number of points is less than 2.
- * @throws org.apache.commons.math3.exception.NonMonotonicSequenceException
+ * @throws NonMonotonicSequenceException
* if two abscissae have the same value.
*/
- public PolynomialFunctionLagrangeForm(double x[], double y[]) {
+ public PolynomialFunctionLagrangeForm(double x[], double y[])
+ throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException {
this.x = new double[x.length];
this.y = new double[y.length];
System.arraycopy(x, 0, this.x, 0, x.length);
@@ -163,12 +165,13 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
* @return the function value.
* @throws DimensionMismatchException if {@code x} and {@code y} have
* different lengths.
- * @throws org.apache.commons.math3.exception.NonMonotonicSequenceException
+ * @throws NonMonotonicSequenceException
* if {@code x} is not sorted in strictly increasing order.
* @throws NumberIsTooSmallException if the size of {@code x} is less
* than 2.
*/
- public static double evaluate(double x[], double y[], double z) {
+ public static double evaluate(double x[], double y[], double z)
+ throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException {
if (verifyInterpolationArray(x, y, false)) {
return evaluateInternal(x, y, z);
}
@@ -310,7 +313,8 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
* @see #evaluate(double[], double[], double)
* @see #computeCoefficients()
*/
- public static boolean verifyInterpolationArray(double x[], double y[], boolean abort) {
+ public static boolean verifyInterpolationArray(double x[], double y[], boolean abort)
+ throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException {
if (x.length != y.length) {
throw new DimensionMismatchException(x.length, y.length);
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java
index 0db046413..4042a2d51 100644
--- a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java
+++ b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java
@@ -20,7 +20,9 @@ import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NoDataException;
+import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
+import org.apache.commons.math3.util.MathUtils;
/**
* Implements the representation of a real polynomial function in
@@ -69,13 +71,13 @@ public class PolynomialFunctionNewtonForm implements UnivariateDifferentiableFun
*
* @param a Coefficients in Newton form formula.
* @param c Centers.
- * @throws org.apache.commons.math3.exception.NullArgumentException if
- * any argument is {@code null}.
+ * @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.
*/
- public PolynomialFunctionNewtonForm(double a[], double c[]) {
+ public PolynomialFunctionNewtonForm(double a[], double c[])
+ throws NullArgumentException, NoDataException, DimensionMismatchException {
verifyInputArray(a, c);
this.a = new double[a.length];
@@ -172,13 +174,13 @@ public class PolynomialFunctionNewtonForm implements UnivariateDifferentiableFun
* @param c Centers.
* @param z Point at which the function value is to be computed.
* @return the function value.
- * @throws org.apache.commons.math3.exception.NullArgumentException if
- * any argument is {@code null}.
+ * @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.
*/
- public static double evaluate(double a[], double c[], double z) {
+ public static double evaluate(double a[], double c[], double z)
+ throws NullArgumentException, DimensionMismatchException, NoDataException {
verifyInputArray(a, c);
final int n = c.length;
@@ -221,17 +223,18 @@ public class PolynomialFunctionNewtonForm implements UnivariateDifferentiableFun
*
* @param a the coefficients in Newton form formula
* @param c the centers
- * @throws org.apache.commons.math3.exception.NullArgumentException if
- * any argument is {@code null}.
+ * @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[]) {
- if (a.length == 0 ||
- c.length == 0) {
+ 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) {
diff --git a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
index 875fdc0b3..78906c947 100644
--- a/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
+++ b/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
@@ -23,6 +23,7 @@ import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.DimensionMismatchException;
@@ -95,11 +96,12 @@ public class PolynomialSplineFunction implements UnivariateDifferentiableFunctio
* @throws NullArgumentException if either of the input arrays is {@code null}.
* @throws NumberIsTooSmallException if knots has length less than 2.
* @throws DimensionMismatchException if {@code polynomials.length != knots.length - 1}.
- * @throws org.apache.commons.math3.exception.NonMonotonicSequenceException if
- * the {@code knots} array is not strictly increasing.
+ * @throws NonMonotonicSequenceException if the {@code knots} array is not strictly increasing.
*
*/
- public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[]) {
+ public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[])
+ throws NullArgumentException, NumberIsTooSmallException,
+ DimensionMismatchException, NonMonotonicSequenceException{
if (knots == null ||
polynomials == null) {
throw new NullArgumentException();
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
index 8dbcbe8c0..91869c5ff 100644
--- a/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
+++ b/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
@@ -63,8 +63,7 @@ public abstract class AbstractDifferentiableUnivariateSolver
*
* @param point Point at which the objective function must be evaluated.
* @return the objective function value at specified point.
- * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
- * if the maximal number of evaluations is exceeded.
+ * @throws TooManyEvaluationsException if the maximal number of evaluations is exceeded.
*/
protected double computeDerivativeObjectiveValue(double point)
throws TooManyEvaluationsException {
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java
index 4b44da3f8..c9fd38d3f 100644
--- a/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java
+++ b/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysis.solvers;
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
+import org.apache.commons.math3.exception.TooManyEvaluationsException;
/**
* Provide a default implementation for several functions useful to generic
@@ -61,10 +62,11 @@ public abstract class AbstractUnivariateDifferentiableSolver
*
* @param point Point at which the objective function must be evaluated.
* @return the objective function value and derivative at specified point.
- * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
+ * @throws TooManyEvaluationsException
* if the maximal number of evaluations is exceeded.
*/
- protected DerivativeStructure computeObjectiveValueAndDerivative(double point) {
+ protected DerivativeStructure computeObjectiveValueAndDerivative(double point)
+ throws TooManyEvaluationsException {
incrementEvaluationCount();
return function.value(new DerivativeStructure(1, 1, 0, point));
}
diff --git a/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java b/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
index 2f2afeb0f..253fcf012 100644
--- a/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
+++ b/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
@@ -166,11 +166,13 @@ public abstract class BaseAbstractUnivariateSolver {
* @param min Lower bound for the interval.
* @param max Upper bound for the interval.
* @return a value where the function is zero.
- * @throws org.apache.commons.math3.exception.MathIllegalArgumentException
+ * @throws MathIllegalArgumentException
* if the arguments do not satisfy the requirements specified by the solver.
- * @throws org.apache.commons.math3.exception.TooManyEvaluationsException if
+ * @throws TooManyEvaluationsException if
* the allowed number of evaluations is exceeded.
*/
- double solve(int maxEval, FUNC f, double min, double max);
+ double solve(int maxEval, FUNC f, double min, double max)
+ throws MathIllegalArgumentException, TooManyEvaluationsException;
/**
* Solve for a zero in the given interval, start at {@code startValue}.
@@ -116,12 +119,13 @@ public interface BaseUnivariateSolver {
* @param max Upper bound for the interval.
* @param startValue Start value to use.
* @return a value where the function is zero.
- * @throws org.apache.commons.math3.exception.MathIllegalArgumentException
+ * @throws MathIllegalArgumentException
* if the arguments do not satisfy the requirements specified by the solver.
- * @throws org.apache.commons.math3.exception.TooManyEvaluationsException if
+ * @throws TooManyEvaluationsException if
* the allowed number of evaluations is exceeded.
*/
- double solve(int maxEval, FUNC f, double min, double max, double startValue);
+ double solve(int maxEval, FUNC f, double min, double max, double startValue)
+ throws MathIllegalArgumentException, TooManyEvaluationsException;
/**
* Solve for a zero in the vicinity of {@code startValue}.
diff --git a/src/main/java/org/apache/commons/math3/util/Incrementor.java b/src/main/java/org/apache/commons/math3/util/Incrementor.java
index 79e695ee4..8f798e8f0 100644
--- a/src/main/java/org/apache/commons/math3/util/Incrementor.java
+++ b/src/main/java/org/apache/commons/math3/util/Incrementor.java
@@ -62,7 +62,7 @@ public class Incrementor {
this(max,
new MaxCountExceededCallback() {
/** {@inheritDoc} */
- public void trigger(int max) {
+ public void trigger(int max) throws MaxCountExceededException {
throw new MaxCountExceededException(max);
}
});
@@ -76,8 +76,8 @@ public class Incrementor {
* @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) {
+ public Incrementor(int max, MaxCountExceededCallback cb)
+ throws NullArgumentException {
if (cb == null){
throw new NullArgumentException();
}
@@ -132,7 +132,7 @@ public class Incrementor {
* @param value Number of increments.
* @throws MaxCountExceededException at counter exhaustion.
*/
- public void incrementCount(int value) {
+ public void incrementCount(int value) throws MaxCountExceededException {
for (int i = 0; i < value; i++) {
incrementCount();
}
@@ -151,7 +151,7 @@ public class Incrementor {
* custom {@link MaxCountExceededCallback callback} has been set at
* construction.
*/
- public void incrementCount() {
+ public void incrementCount() throws MaxCountExceededException {
if (++count > maximalCount) {
maxCountCallback.trigger(maximalCount);
}
@@ -173,7 +173,8 @@ public class Incrementor {
* Function called when the maximal count has been reached.
*
* @param maximalCount Maximal count.
+ * @throws MaxCountExceededException at counter exhaustion
*/
- void trigger(int maximalCount);
+ void trigger(int maximalCount) throws MaxCountExceededException;
}
}
diff --git a/src/main/java/org/apache/commons/math3/util/MathArrays.java b/src/main/java/org/apache/commons/math3/util/MathArrays.java
index 045a9cd86..0ca75e94c 100644
--- a/src/main/java/org/apache/commons/math3/util/MathArrays.java
+++ b/src/main/java/org/apache/commons/math3/util/MathArrays.java
@@ -83,8 +83,8 @@ public class MathArrays {
* @throws DimensionMismatchException if the array lengths differ.
* @since 3.1
*/
- public static double[] ebeAdd(double[] a,
- double[] b) {
+ public static double[] ebeAdd(double[] a, double[] b)
+ throws DimensionMismatchException {
if (a.length != b.length) {
throw new DimensionMismatchException(a.length, b.length);
}
@@ -105,8 +105,8 @@ public class MathArrays {
* @throws DimensionMismatchException if the array lengths differ.
* @since 3.1
*/
- public static double[] ebeSubtract(double[] a,
- double[] b) {
+ public static double[] ebeSubtract(double[] a, double[] b)
+ throws DimensionMismatchException {
if (a.length != b.length) {
throw new DimensionMismatchException(a.length, b.length);
}
@@ -127,8 +127,8 @@ public class MathArrays {
* @throws DimensionMismatchException if the array lengths differ.
* @since 3.1
*/
- public static double[] ebeMultiply(double[] a,
- double[] b) {
+ public static double[] ebeMultiply(double[] a, double[] b)
+ throws DimensionMismatchException {
if (a.length != b.length) {
throw new DimensionMismatchException(a.length, b.length);
}
@@ -149,8 +149,8 @@ public class MathArrays {
* @throws DimensionMismatchException if the array lengths differ.
* @since 3.1
*/
- public static double[] ebeDivide(double[] a,
- double[] b) {
+ public static double[] ebeDivide(double[] a, double[] b)
+ throws DimensionMismatchException {
if (a.length != b.length) {
throw new DimensionMismatchException(a.length, b.length);
}
@@ -323,9 +323,7 @@ public class MathArrays {
* @param strict Whether the order should be strict.
* @return {@code true} if sorted, {@code false} otherwise.
*/
- public static boolean isMonotonic(double[] val,
- OrderDirection dir,
- boolean strict) {
+ public static boolean isMonotonic(double[] val, OrderDirection dir, boolean strict) {
return checkOrder(val, dir, strict, false);
}