You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2013/03/11 16:45:55 UTC
svn commit: r1455194 [1/2] - in
/commons/proper/math/trunk/src/main/java/org/apache/commons/math3:
analysis/ analysis/differentiation/ analysis/function/
analysis/integration/ analysis/integration/gauss/ analysis/interpolation/
analysis/polynomials/ an...
Author: luc
Date: Mon Mar 11 15:45:54 2013
New Revision: 1455194
URL: http://svn.apache.org/r1455194
Log:
Filled throws clauses for the analysis package.
JIRA: MATH-854
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/GradientFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/JacobianFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/UnivariateDifferentiableFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Gaussian.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/HarmonicOscillator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sigmoid.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sinc.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/StepFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/BaseRuleFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegratorFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseUnivariateSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java Mon Mar 11 15:45:54 2013
@@ -172,8 +172,11 @@ public class FunctionUtils {
return r;
}
- /** {@inheritDoc} */
- public DerivativeStructure value(final DerivativeStructure t) {
+ /** {@inheritDoc}
+ * @throws DimensionMismatchException if functions are not consistent with each other
+ */
+ public DerivativeStructure value(final DerivativeStructure t)
+ throws DimensionMismatchException {
DerivativeStructure r = f[0].value(t);
for (int i = 1; i < f.length; i++) {
r = r.add(f[i].value(t));
@@ -418,8 +421,8 @@ public class FunctionUtils {
* @throws NotStrictlyPositiveException if the number of sample points
* {@code n} is negative.
*/
- public static double[] sample(UnivariateFunction f,
- double min, double max, int n) {
+ public static double[] sample(UnivariateFunction f, double min, double max, int n)
+ throws NumberIsTooLargeException, NotStrictlyPositiveException {
if (n <= 0) {
throw new NotStrictlyPositiveException(
@@ -609,8 +612,8 @@ public class FunctionUtils {
}
/** {@inheritDoc}
- * @exception DimensionMismatchException if number of parameters or derivation
- * order are higher than 1
+ * @exception NumberIsTooLargeException if derivation order is higher than 1
+ * @exception DimensionMismatchException if numbers of free parameters are inconsistent
*/
public DerivativeStructure value(final DerivativeStructure[] t)
throws DimensionMismatchException, NumberIsTooLargeException {
@@ -732,8 +735,8 @@ public class FunctionUtils {
}
/** {@inheritDoc}
- * @exception DimensionMismatchException if number of parameters or derivation
- * order are higher than 1
+ * @exception NumberIsTooLargeException if derivation order is higher than 1
+ * @exception DimensionMismatchException if numbers of free parameters are inconsistent
*/
public DerivativeStructure[] value(final DerivativeStructure[] t)
throws DimensionMismatchException, NumberIsTooLargeException {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java Mon Mar 11 15:45:54 2013
@@ -22,6 +22,9 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathArithmeticException;
+import org.apache.commons.math3.exception.MathInternalError;
+import org.apache.commons.math3.exception.NotPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.util.ArithmeticUtils;
import org.apache.commons.math3.util.FastMath;
@@ -154,9 +157,11 @@ public class DSCompiler {
* @param order derivation order
* @param valueCompiler compiler for the value part
* @param derivativeCompiler compiler for the derivative part
+ * @throws NumberIsTooLargeException if order is too large
*/
private DSCompiler(final int parameters, final int order,
- final DSCompiler valueCompiler, final DSCompiler derivativeCompiler) {
+ final DSCompiler valueCompiler, final DSCompiler derivativeCompiler)
+ throws NumberIsTooLargeException {
this.parameters = parameters;
this.order = order;
@@ -181,8 +186,10 @@ public class DSCompiler {
* @param parameters number of free parameters
* @param order derivation order
* @return cached rules set
+ * @throws NumberIsTooLargeException if order is too large
*/
- public static DSCompiler getCompiler(int parameters, int order) {
+ public static DSCompiler getCompiler(int parameters, int order)
+ throws NumberIsTooLargeException {
// get the cached compilers
final DSCompiler[][] cache = compilers.get();
@@ -400,12 +407,14 @@ public class DSCompiler {
* @param sizes sizes array
* @param derivativesIndirection derivatives indirection array
* @return multiplication indirection array
+ * @throws NumberIsTooLargeException if order is too large
*/
private static int[][][] compileCompositionIndirection(final int parameters, final int order,
- final DSCompiler valueCompiler,
- final DSCompiler derivativeCompiler,
- final int[][] sizes,
- final int[][] derivativesIndirection) {
+ final DSCompiler valueCompiler,
+ final DSCompiler derivativeCompiler,
+ final int[][] sizes,
+ final int[][] derivativesIndirection)
+ throws NumberIsTooLargeException {
if ((parameters == 0) || (order == 0)) {
return new int[][][] { { { 1, 0 } } };
@@ -596,10 +605,12 @@ public class DSCompiler {
* @param destSizes sizes array for the destination derivative structure
* @return index of the partial derivative with the <em>same</em> characteristics
* in destination derivative structure
+ * @throws NumberIsTooLargeException if order is too large
*/
private static int convertIndex(final int index,
final int srcP, final int[][] srcDerivativesIndirection,
- final int destP, final int destO, final int[][] destSizes) {
+ final int destP, final int destO, final int[][] destSizes)
+ throws NumberIsTooLargeException {
int[] orders = new int[destP];
System.arraycopy(srcDerivativesIndirection[index], 0, orders, 0, FastMath.min(srcP, destP));
return getPartialDerivativeIndex(destP, destO, destSizes, orders);
@@ -1730,15 +1741,23 @@ public class DSCompiler {
* @param dsOffset offset of the derivative structure in its array
* @param delta parameters offsets (Δx, Δy, ...)
* @return value of the Taylor expansion at x + Δx, y + Δy, ...
+ * @throws MathArithmeticException if factorials becomes too large
*/
- public double taylor(final double[] ds, final int dsOffset, final double ... delta) {
+ public double taylor(final double[] ds, final int dsOffset, final double ... delta)
+ throws MathArithmeticException {
double value = 0;
for (int i = getSize() - 1; i >= 0; --i) {
final int[] orders = getPartialDerivativeOrders(i);
double term = ds[dsOffset + i];
for (int k = 0; k < orders.length; ++k) {
if (orders[k] > 0) {
- term *= FastMath.pow(delta[k], orders[k]) / ArithmeticUtils.factorial(orders[k]);
+ try {
+ term *= FastMath.pow(delta[k], orders[k]) /
+ ArithmeticUtils.factorial(orders[k]);
+ } catch (NotPositiveException e) {
+ // this cannot happen
+ throw new MathInternalError(e);
+ }
}
}
value += term;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/DerivativeStructure.java Mon Mar 11 15:45:54 2013
@@ -22,6 +22,7 @@ import org.apache.commons.math3.RealFiel
import org.apache.commons.math3.Field;
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.NumberIsTooLargeException;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathArrays;
@@ -80,8 +81,10 @@ public class DerivativeStructure impleme
/** Build an instance with all values and derivatives set to 0.
* @param parameters number of free parameters
* @param order derivation order
+ * @throws NumberIsTooLargeException if order is too large
*/
- public DerivativeStructure(final int parameters, final int order) {
+ public DerivativeStructure(final int parameters, final int order)
+ throws NumberIsTooLargeException {
this(DSCompiler.getCompiler(parameters, order));
}
@@ -89,9 +92,11 @@ public class DerivativeStructure impleme
* @param parameters number of free parameters
* @param order derivation order
* @param value value of the constant
+ * @throws NumberIsTooLargeException if order is too large
* @see #DerivativeStructure(int, int, int, double)
*/
- public DerivativeStructure(final int parameters, final int order, final double value) {
+ public DerivativeStructure(final int parameters, final int order, final double value)
+ throws NumberIsTooLargeException {
this(parameters, order);
this.data[0] = value;
}
@@ -193,10 +198,11 @@ public class DerivativeStructure impleme
* {@link DSCompiler#getPartialDerivativeIndex(int...)}
* @exception DimensionMismatchException if derivatives array does not match the
* {@link DSCompiler#getSize() size} expected by the compiler
+ * @throws NumberIsTooLargeException if order is too large
* @see #getAllDerivatives()
*/
public DerivativeStructure(final int parameters, final int order, final double ... derivatives)
- throws DimensionMismatchException {
+ throws DimensionMismatchException, NumberIsTooLargeException {
this(parameters, order);
if (derivatives.length != data.length) {
throw new DimensionMismatchException(derivatives.length, data.length);
@@ -269,7 +275,10 @@ public class DerivativeStructure impleme
return ds;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure add(final DerivativeStructure a)
throws DimensionMismatchException {
compiler.checkCompatibility(a.compiler);
@@ -283,7 +292,10 @@ public class DerivativeStructure impleme
return add(-a);
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure subtract(final DerivativeStructure a)
throws DimensionMismatchException {
compiler.checkCompatibility(a.compiler);
@@ -306,7 +318,10 @@ public class DerivativeStructure impleme
return ds;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure multiply(final DerivativeStructure a)
throws DimensionMismatchException {
compiler.checkCompatibility(a.compiler);
@@ -324,7 +339,10 @@ public class DerivativeStructure impleme
return ds;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure divide(final DerivativeStructure a)
throws DimensionMismatchException {
compiler.checkCompatibility(a.compiler);
@@ -340,7 +358,10 @@ public class DerivativeStructure impleme
return ds;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure remainder(final DerivativeStructure a)
throws DimensionMismatchException {
compiler.checkCompatibility(a.compiler);
@@ -412,7 +433,7 @@ public class DerivativeStructure impleme
}
/** {@inheritDoc} */
- public DerivativeStructure copySign(final double sign){
+ public DerivativeStructure copySign(final double sign) {
long m = Double.doubleToLongBits(data[0]);
long s = Double.doubleToLongBits(sign);
if ((m >= 0 && s >= 0) || (m < 0 && s < 0)) { // Sign is currently OK
@@ -442,7 +463,10 @@ public class DerivativeStructure impleme
return ds;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure hypot(final DerivativeStructure y)
throws DimensionMismatchException {
@@ -500,7 +524,8 @@ public class DerivativeStructure impleme
* @param x a value
* @param y a value
* @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
- * @exception DimensionMismatchException if number of free parameters or orders are inconsistent
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
*/
public static DerivativeStructure hypot(final DerivativeStructure x, final DerivativeStructure y)
throws DimensionMismatchException {
@@ -515,7 +540,8 @@ public class DerivativeStructure impleme
* @exception DimensionMismatchException if the number of derivatives
* in the array is not equal to {@link #getOrder() order} + 1
*/
- public DerivativeStructure compose(final double ... f) {
+ public DerivativeStructure compose(final double ... f)
+ throws DimensionMismatchException {
if (f.length != getOrder() + 1) {
throw new DimensionMismatchException(f.length, getOrder() + 1);
}
@@ -584,7 +610,10 @@ public class DerivativeStructure impleme
return result;
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure pow(final DerivativeStructure e)
throws DimensionMismatchException {
compiler.checkCompatibility(e.compiler);
@@ -685,7 +714,8 @@ public class DerivativeStructure impleme
* @param y first argument of the arc tangent
* @param x second argument of the arc tangent
* @return atan2(y, x)
- * @exception DimensionMismatchException if number of free parameters or orders are inconsistent
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
*/
public static DerivativeStructure atan2(final DerivativeStructure y, final DerivativeStructure x)
throws DimensionMismatchException {
@@ -759,12 +789,16 @@ public class DerivativeStructure impleme
/** Evaluate Taylor expansion a derivative structure.
* @param delta parameters offsets (Δx, Δy, ...)
* @return value of the Taylor expansion at x + Δx, y + Δy, ...
+ * @throws MathArithmeticException if factorials becomes too large
*/
- public double taylor(final double ... delta) {
+ public double taylor(final double ... delta) throws MathArithmeticException {
return compiler.taylor(data, 0, delta);
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final DerivativeStructure[] a, final DerivativeStructure[] b)
throws DimensionMismatchException {
@@ -792,7 +826,10 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final double[] a, final DerivativeStructure[] b)
throws DimensionMismatchException {
@@ -816,9 +853,13 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
- final DerivativeStructure a2, final DerivativeStructure b2) {
+ final DerivativeStructure a2, final DerivativeStructure b2)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1.getValue(), b1.getValue(),
@@ -834,9 +875,13 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
- final double a2, final DerivativeStructure b2) {
+ final double a2, final DerivativeStructure b2)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1, b1.getValue(),
@@ -852,10 +897,14 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
final DerivativeStructure a2, final DerivativeStructure b2,
- final DerivativeStructure a3, final DerivativeStructure b3) {
+ final DerivativeStructure a3, final DerivativeStructure b3)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1.getValue(), b1.getValue(),
@@ -872,10 +921,14 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
final double a2, final DerivativeStructure b2,
- final double a3, final DerivativeStructure b3) {
+ final double a3, final DerivativeStructure b3)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1, b1.getValue(),
@@ -892,11 +945,15 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final DerivativeStructure a1, final DerivativeStructure b1,
final DerivativeStructure a2, final DerivativeStructure b2,
final DerivativeStructure a3, final DerivativeStructure b3,
- final DerivativeStructure a4, final DerivativeStructure b4) {
+ final DerivativeStructure a4, final DerivativeStructure b4)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1.getValue(), b1.getValue(),
@@ -914,11 +971,15 @@ public class DerivativeStructure impleme
}
- /** {@inheritDoc} */
+ /** {@inheritDoc}
+ * @exception DimensionMismatchException if number of free parameters
+ * or orders do not match
+ */
public DerivativeStructure linearCombination(final double a1, final DerivativeStructure b1,
final double a2, final DerivativeStructure b2,
final double a3, final DerivativeStructure b3,
- final double a4, final DerivativeStructure b4) {
+ final double a4, final DerivativeStructure b4)
+ throws DimensionMismatchException {
// compute an accurate value, taking care of cancellations
final double accurateValue = MathArrays.linearCombination(a1, b1.getValue(),
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/GradientFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/GradientFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/GradientFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/GradientFunction.java Mon Mar 11 15:45:54 2013
@@ -39,8 +39,7 @@ public class GradientFunction implements
}
/** {@inheritDoc} */
- public double[] value(double[] point)
- throws IllegalArgumentException {
+ public double[] value(double[] point) {
// set up parameters
final DerivativeStructure[] dsX = new DerivativeStructure[point.length];
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/JacobianFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/JacobianFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/JacobianFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/JacobianFunction.java Mon Mar 11 15:45:54 2013
@@ -41,8 +41,7 @@ public class JacobianFunction implements
}
/** {@inheritDoc} */
- public double[][] value(double[] point)
- throws IllegalArgumentException {
+ public double[][] value(double[] point) {
// set up parameters
final DerivativeStructure[] dsX = new DerivativeStructure[point.length];
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/UnivariateDifferentiableFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/UnivariateDifferentiableFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/UnivariateDifferentiableFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/differentiation/UnivariateDifferentiableFunction.java Mon Mar 11 15:45:54 2013
@@ -17,7 +17,7 @@
package org.apache.commons.math3.analysis.differentiation;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.DimensionMismatchException;
/** Interface for univariate functions derivatives.
* <p>This interface represents a simple function which computes
@@ -35,10 +35,10 @@ public interface UnivariateDifferentiabl
* value and the first derivative of the function.</p>
* @param t function input value
* @return function result
- * @exception MathIllegalArgumentException if {@code t} does not
- * fulfill functions constraints (argument out of bound, or unsupported
- * derivative order for example)
+ * @exception DimensionMismatchException if t is inconsistent with
+ * function free parameters or order
*/
- DerivativeStructure value(DerivativeStructure t) throws MathIllegalArgumentException;
+ DerivativeStructure value(DerivativeStructure t)
+ throws DimensionMismatchException;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Gaussian.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Gaussian.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Gaussian.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Gaussian.java Mon Mar 11 15:45:54 2013
@@ -209,7 +209,8 @@ public class Gaussian implements Univari
/** {@inheritDoc}
* @since 3.1
*/
- public DerivativeStructure value(final DerivativeStructure t) {
+ public DerivativeStructure value(final DerivativeStructure t)
+ throws DimensionMismatchException {
final double u = is * (t.getValue() - mean);
double[] f = new double[t.getOrder() + 1];
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/HarmonicOscillator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/HarmonicOscillator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/HarmonicOscillator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/HarmonicOscillator.java Mon Mar 11 15:45:54 2013
@@ -162,7 +162,8 @@ public class HarmonicOscillator implemen
/** {@inheritDoc}
* @since 3.1
*/
- public DerivativeStructure value(final DerivativeStructure t) {
+ public DerivativeStructure value(final DerivativeStructure t)
+ throws DimensionMismatchException {
final double x = t.getValue();
double[] f = new double[t.getOrder() + 1];
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sigmoid.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sigmoid.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sigmoid.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sigmoid.java Mon Mar 11 15:45:54 2013
@@ -164,7 +164,8 @@ public class Sigmoid implements Univaria
/** {@inheritDoc}
* @since 3.1
*/
- public DerivativeStructure value(final DerivativeStructure t) {
+ public DerivativeStructure value(final DerivativeStructure t)
+ throws DimensionMismatchException {
double[] f = new double[t.getOrder() + 1];
final double exp = FastMath.exp(-t.getValue());
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sinc.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sinc.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sinc.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/Sinc.java Mon Mar 11 15:45:54 2013
@@ -22,6 +22,7 @@ import org.apache.commons.math3.analysis
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.DimensionMismatchException;
import org.apache.commons.math3.util.FastMath;
/**
@@ -105,7 +106,8 @@ public class Sinc implements UnivariateD
/** {@inheritDoc}
* @since 3.1
*/
- public DerivativeStructure value(final DerivativeStructure t) {
+ public DerivativeStructure value(final DerivativeStructure t)
+ throws DimensionMismatchException {
final double scaledX = (normalized ? FastMath.PI : 1) * t.getValue();
final double scaledX2 = scaledX * scaledX;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/StepFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/StepFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/StepFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/function/StepFunction.java Mon Mar 11 15:45:54 2013
@@ -20,6 +20,7 @@ package org.apache.commons.math3.analysi
import java.util.Arrays;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.NoDataException;
import org.apache.commons.math3.util.MathArrays;
@@ -50,7 +51,7 @@ public class StepFunction implements Uni
*
* @param x Domain values where the function changes value.
* @param y Values of the function.
- * @throws org.apache.commons.math3.exception.NonMonotonicSequenceException
+ * @throws NonMonotonicSequenceException
* if the {@code x} array is not sorted in strictly increasing order.
* @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
* @throws NoDataException if {@code x} or {@code y} are zero-length.
@@ -59,9 +60,8 @@ public class StepFunction implements Uni
*/
public StepFunction(double[] x,
double[] y)
- throws NullArgumentException,
- NoDataException,
- DimensionMismatchException {
+ throws NullArgumentException, NoDataException,
+ DimensionMismatchException, NonMonotonicSequenceException {
if (x == null ||
y == null) {
throw new NullArgumentException();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/BaseAbstractUnivariateIntegrator.java Mon Mar 11 15:45:54 2013
@@ -107,9 +107,9 @@ public abstract class BaseAbstractUnivar
* is lesser than or equal to the minimal number of iterations
*/
protected BaseAbstractUnivariateIntegrator(final double relativeAccuracy,
- final double absoluteAccuracy,
- final int minimalIterationCount,
- final int maximalIterationCount)
+ final double absoluteAccuracy,
+ final int minimalIterationCount,
+ final int maximalIterationCount)
throws NotStrictlyPositiveException, NumberIsTooSmallException {
// accuracy settings
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegrator.java Mon Mar 11 15:45:54 2013
@@ -19,10 +19,12 @@ package org.apache.commons.math3.analysi
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory;
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;
/**
@@ -52,7 +54,7 @@ public class IterativeLegendreGaussInteg
* @param minimalIterationCount Minimum number of iterations.
* @param maximalIterationCount Maximum number of iterations.
* @throws NotStrictlyPositiveException if minimal number of iterations
- * is not strictly positive.
+ * or number of points are not strictly positive.
* @throws NumberIsTooSmallException if maximal number of iterations
* is smaller than or equal to the minimal number of iterations.
*/
@@ -63,7 +65,10 @@ public class IterativeLegendreGaussInteg
final int maximalIterationCount)
throws NotStrictlyPositiveException, NumberIsTooSmallException {
super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);
- numberOfPoints = n;
+ if (n <= 0) {
+ throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS, n);
+ }
+ numberOfPoints = n;
}
/**
@@ -72,10 +77,12 @@ public class IterativeLegendreGaussInteg
* @param n Number of integration points.
* @param relativeAccuracy Relative accuracy of the result.
* @param absoluteAccuracy Absolute accuracy of the result.
+ * @throws NotStrictlyPositiveException if {@code n < 1}.
*/
public IterativeLegendreGaussIntegrator(final int n,
final double relativeAccuracy,
- final double absoluteAccuracy) {
+ final double absoluteAccuracy)
+ throws NotStrictlyPositiveException {
this(n, relativeAccuracy, absoluteAccuracy,
DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);
}
@@ -90,10 +97,12 @@ public class IterativeLegendreGaussInteg
* is not strictly positive.
* @throws NumberIsTooSmallException if maximal number of iterations
* is smaller than or equal to the minimal number of iterations.
+ * @throws NotStrictlyPositiveException if {@code n < 1}.
*/
public IterativeLegendreGaussIntegrator(final int n,
final int minimalIterationCount,
- final int maximalIterationCount) {
+ final int maximalIterationCount)
+ throws NotStrictlyPositiveException, NumberIsTooSmallException {
this(n, DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,
minimalIterationCount, maximalIterationCount);
}
@@ -101,7 +110,7 @@ public class IterativeLegendreGaussInteg
/** {@inheritDoc} */
@Override
protected double doIntegrate()
- throws TooManyEvaluationsException, MaxCountExceededException {
+ throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {
// Compute first estimate with a single step.
double oldt = stage(1);
@@ -142,7 +151,8 @@ public class IterativeLegendreGaussInteg
throws TooManyEvaluationsException {
// Function to be integrated is stored in the base class.
final UnivariateFunction f = new UnivariateFunction() {
- public double value(double x) {
+ public double value(double x)
+ throws MathIllegalArgumentException, TooManyEvaluationsException {
return computeObjectiveValue(x);
}
};
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegrator.java Mon Mar 11 15:45:54 2013
@@ -128,6 +128,7 @@ public class LegendreGaussIntegrator ext
* @param absoluteAccuracy absolute accuracy of the result
* @param minimalIterationCount minimum number of iterations
* @param maximalIterationCount maximum number of iterations
+ * @exception MathIllegalArgumentException if number of points is out of [2; 5]
* @exception NotStrictlyPositiveException if minimal number of iterations
* is not strictly positive
* @exception NumberIsTooSmallException if maximal number of iterations
@@ -138,7 +139,7 @@ public class LegendreGaussIntegrator ext
final double absoluteAccuracy,
final int minimalIterationCount,
final int maximalIterationCount)
- throws NotStrictlyPositiveException, NumberIsTooSmallException {
+ throws MathIllegalArgumentException, NotStrictlyPositiveException, NumberIsTooSmallException {
super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);
switch(n) {
case 2 :
@@ -170,10 +171,12 @@ public class LegendreGaussIntegrator ext
* @param n number of points desired (must be between 2 and 5 inclusive)
* @param relativeAccuracy relative accuracy of the result
* @param absoluteAccuracy absolute accuracy of the result
+ * @exception MathIllegalArgumentException if number of points is out of [2; 5]
*/
public LegendreGaussIntegrator(final int n,
final double relativeAccuracy,
- final double absoluteAccuracy) {
+ final double absoluteAccuracy)
+ throws MathIllegalArgumentException {
this(n, relativeAccuracy, absoluteAccuracy,
DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);
}
@@ -183,6 +186,7 @@ public class LegendreGaussIntegrator ext
* @param n number of points desired (must be between 2 and 5 inclusive)
* @param minimalIterationCount minimum number of iterations
* @param maximalIterationCount maximum number of iterations
+ * @exception MathIllegalArgumentException if number of points is out of [2; 5]
* @exception NotStrictlyPositiveException if minimal number of iterations
* is not strictly positive
* @exception NumberIsTooSmallException if maximal number of iterations
@@ -190,7 +194,8 @@ public class LegendreGaussIntegrator ext
*/
public LegendreGaussIntegrator(final int n,
final int minimalIterationCount,
- final int maximalIterationCount) {
+ final int maximalIterationCount)
+ throws MathIllegalArgumentException {
this(n, DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,
minimalIterationCount, maximalIterationCount);
}
@@ -198,7 +203,7 @@ public class LegendreGaussIntegrator ext
/** {@inheritDoc} */
@Override
protected double doIntegrate()
- throws TooManyEvaluationsException, MaxCountExceededException {
+ throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {
// compute first estimate with a single step
double oldt = stage(1);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegrator.java Mon Mar 11 15:45:54 2013
@@ -16,6 +16,7 @@
*/
package org.apache.commons.math3.analysis.integration;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
@@ -144,7 +145,7 @@ public class TrapezoidIntegrator extends
/** {@inheritDoc} */
@Override
protected double doIntegrate()
- throws TooManyEvaluationsException, MaxCountExceededException {
+ throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {
double oldt = stage(this, 0);
iterations.incrementCount();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/BaseRuleFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/BaseRuleFactory.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/BaseRuleFactory.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/BaseRuleFactory.java Mon Mar 11 15:45:54 2013
@@ -21,6 +21,7 @@ import java.util.TreeMap;
import org.apache.commons.math3.util.Pair;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
/**
* Base class for rules that determines the integration nodes and their
@@ -48,9 +49,17 @@ public abstract class BaseRuleFactory<T
* @param numberOfPoints Number of integration points.
* @return a copy of the integration rule.
* @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
+ * @throws DimensionMismatchException if the elements of the rule pair do not
+ * have the same length.
*/
public Pair<double[], double[]> getRule(int numberOfPoints)
- throws NotStrictlyPositiveException {
+ throws NotStrictlyPositiveException, DimensionMismatchException {
+
+ if (numberOfPoints <= 0) {
+ throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
+ numberOfPoints);
+ }
+
// Try to obtain the rule from the cache.
Pair<double[], double[]> cached = pointsAndWeightsDouble.get(numberOfPoints);
@@ -78,10 +87,11 @@ public abstract class BaseRuleFactory<T
*
* @param numberOfPoints Order of the rule to be retrieved.
* @return the points and weights corresponding to the given order.
- * @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
+ * @throws DimensionMismatchException if the elements of the rule pair do not
+ * have the same length.
*/
protected synchronized Pair<T[], T[]> getRuleInternal(int numberOfPoints)
- throws NotStrictlyPositiveException {
+ throws DimensionMismatchException {
final Pair<T[], T[]> rule = pointsAndWeights.get(numberOfPoints);
if (rule == null) {
addRule(computeRule(numberOfPoints));
@@ -98,7 +108,7 @@ public abstract class BaseRuleFactory<T
* @throws DimensionMismatchException if the elements of the pair do not
* have the same length.
*/
- protected void addRule(Pair<T[], T[]> rule) {
+ protected void addRule(Pair<T[], T[]> rule) throws DimensionMismatchException {
if (rule.getFirst().length != rule.getSecond().length) {
throw new DimensionMismatchException(rule.getFirst().length,
rule.getSecond().length);
@@ -112,8 +122,11 @@ public abstract class BaseRuleFactory<T
*
* @param numberOfPoints Order of the rule to be computed.
* @return the computed rule.
+ * @throws DimensionMismatchException if the elements of the pair do not
+ * have the same length.
*/
- protected abstract Pair<T[], T[]> computeRule(int numberOfPoints);
+ protected abstract Pair<T[], T[]> computeRule(int numberOfPoints)
+ throws DimensionMismatchException;
/**
* Converts the from the actual {@code Number} type to {@code double}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegrator.java Mon Mar 11 15:45:54 2013
@@ -45,10 +45,11 @@ public class GaussIntegrator {
* @param weights Weights of the corresponding integration nodes.
* @throws NonMonotonicSequenceException if the {@code points} are not
* sorted in increasing order.
+ * @throws DimensionMismatchException if points and weights don't have the same length
*/
public GaussIntegrator(double[] points,
double[] weights)
- throws NonMonotonicSequenceException {
+ throws NonMonotonicSequenceException, DimensionMismatchException {
if (points.length != weights.length) {
throw new DimensionMismatchException(points.length,
weights.length);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegratorFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegratorFactory.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegratorFactory.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/GaussIntegratorFactory.java Mon Mar 11 15:45:54 2013
@@ -18,6 +18,8 @@ package org.apache.commons.math3.analysi
import java.math.BigDecimal;
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.util.Pair;
/**
@@ -55,10 +57,12 @@ public class GaussIntegratorFactory {
* @param lowerBound Lower bound of the integration interval.
* @param upperBound Upper bound of the integration interval.
* @return a Gauss-Legendre integrator.
+ * @throws NotStrictlyPositiveException if number of points is not positive
*/
public GaussIntegrator legendre(int numberOfPoints,
double lowerBound,
- double upperBound) {
+ double upperBound)
+ throws NotStrictlyPositiveException {
return new GaussIntegrator(transform(getRule(legendre, numberOfPoints),
lowerBound, upperBound));
}
@@ -71,8 +75,10 @@ public class GaussIntegratorFactory {
*
* @param numberOfPoints Order of the integration rule.
* @return a Gauss-Legendre integrator.
+ * @throws NotStrictlyPositiveException if number of points is not positive
*/
- public GaussIntegrator legendreHighPrecision(int numberOfPoints) {
+ public GaussIntegrator legendreHighPrecision(int numberOfPoints)
+ throws NotStrictlyPositiveException {
return new GaussIntegrator(getRule(legendreHighPrecision, numberOfPoints));
}
@@ -85,10 +91,12 @@ public class GaussIntegratorFactory {
* @param lowerBound Lower bound of the integration interval.
* @param upperBound Upper bound of the integration interval.
* @return a Gauss-Legendre integrator.
+ * @throws NotStrictlyPositiveException if number of points is not positive
*/
public GaussIntegrator legendreHighPrecision(int numberOfPoints,
double lowerBound,
- double upperBound) {
+ double upperBound)
+ throws NotStrictlyPositiveException {
return new GaussIntegrator(transform(getRule(legendreHighPrecision, numberOfPoints),
lowerBound, upperBound));
}
@@ -97,9 +105,13 @@ public class GaussIntegratorFactory {
* @param factory Integration rule factory.
* @param numberOfPoints Order of the integration rule.
* @return the integration nodes and weights.
+ * @throws NotStrictlyPositiveException if number of points is not positive
+ * @throws DimensionMismatchException if the elements of the rule pair do not
+ * have the same length.
*/
private static Pair<double[], double[]> getRule(BaseRuleFactory<? extends Number> factory,
- int numberOfPoints) {
+ int numberOfPoints)
+ throws NotStrictlyPositiveException, DimensionMismatchException {
return factory.getRule(numberOfPoints);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java Mon Mar 11 15:45:54 2013
@@ -16,11 +16,11 @@
*/
package org.apache.commons.math3.analysis.integration.gauss;
-import java.math.MathContext;
import java.math.BigDecimal;
+import java.math.MathContext;
+
+import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.util.Pair;
-import org.apache.commons.math3.exception.NotStrictlyPositiveException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
/**
* Factory that creates Gauss-type quadrature rule using Legendre polynomials.
@@ -60,17 +60,10 @@ public class LegendreHighPrecisionRuleFa
oneHalf = new BigDecimal("0.5", mContext);
}
- /**
- * {@inheritDoc}
- *
- * @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
- */
+ /** {@inheritDoc} */
@Override
- protected Pair<BigDecimal[], BigDecimal[]> computeRule(int numberOfPoints) {
- if (numberOfPoints <= 0) {
- throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
- numberOfPoints);
- }
+ protected Pair<BigDecimal[], BigDecimal[]> computeRule(int numberOfPoints)
+ throws DimensionMismatchException {
if (numberOfPoints == 1) {
// Break recursion.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java Mon Mar 11 15:45:54 2013
@@ -16,9 +16,8 @@
*/
package org.apache.commons.math3.analysis.integration.gauss;
+import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.util.Pair;
-import org.apache.commons.math3.exception.NotStrictlyPositiveException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
/**
* Factory that creates Gauss-type quadrature rule using Legendre polynomials.
@@ -32,16 +31,10 @@ import org.apache.commons.math3.exceptio
* @version $Id$
*/
public class LegendreRuleFactory extends BaseRuleFactory<Double> {
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
protected Pair<Double[], Double[]> computeRule(int numberOfPoints)
- throws NotStrictlyPositiveException {
- if (numberOfPoints <= 0) {
- throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
- numberOfPoints);
- }
+ throws DimensionMismatchException {
if (numberOfPoints == 1) {
// Break recursion.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BicubicSplineInterpolator.java Mon Mar 11 15:45:54 2013
@@ -21,6 +21,7 @@ import org.apache.commons.math3.analysis
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();
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/BivariateGridInterpolator.java Mon Mar 11 15:45:54 2013
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysi
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 BivariateGridInterpolat
* @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;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/FieldHermiteInterpolator.java Mon Mar 11 15:45:54 2013
@@ -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.
* <p>
@@ -82,10 +85,14 @@ public class FieldHermiteInterpolator<T
* 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<T
* @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<T
* @return interpolated value and derivatives (value in row 0,
* 1<sup>st</sup> derivative in row 1, ... n<sup>th</sup> 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);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MicrosphereInterpolatingFunction.java Mon Mar 11 15:45:54 2013
@@ -193,8 +193,9 @@ public class MicrosphereInterpolatingFun
/**
* @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.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/MultivariateInterpolator.java Mon Mar 11 15:45:54 2013
@@ -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 MultivariateInterpolato
* 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;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolator.java Mon Mar 11 15:45:54 2013
@@ -18,7 +18,9 @@ package org.apache.commons.math3.analysi
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 SmoothingPolynomialBicubicS
/**
* @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 SmoothingPolynomialBicubicS
* 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 SmoothingPolynomialBicubicS
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();
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TricubicSplineInterpolator.java Mon Mar 11 15:45:54 2013
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysi
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();
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/TrivariateGridInterpolator.java Mon Mar 11 15:45:54 2013
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysi
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 TrivariateGridInterpola
* @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;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariateInterpolator.java Mon Mar 11 15:45:54 2013
@@ -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;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/interpolation/UnivariatePeriodicInterpolator.java Mon Mar 11 15:45:54 2013
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysi
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 UnivariatePeriodicInterpola
*/
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 UnivariatePeriodicInterpola
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));
}
};
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunction.java Mon Mar 11 15:45:54 2013
@@ -405,7 +405,8 @@ public class PolynomialFunction implemen
}
/** {@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);
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionLagrangeForm.java Mon Mar 11 15:45:54 2013
@@ -20,6 +20,7 @@ import org.apache.commons.math3.analysis
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 PolynomialFunctionLagrangeF
* @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 PolynomialFunctionLagrangeF
* @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 PolynomialFunctionLagrangeF
* @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);
}