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 [2/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...
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialFunctionNewtonForm.java Mon Mar 11 15:45:54 2013
@@ -20,7 +20,9 @@ import org.apache.commons.math3.analysis
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 PolynomialFunctionNewtonFor
*
* @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 PolynomialFunctionNewtonFor
* @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 PolynomialFunctionNewtonFor
*
* @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) {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/polynomials/PolynomialSplineFunction.java Mon Mar 11 15:45:54 2013
@@ -23,6 +23,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.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 im
* @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();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractDifferentiableUnivariateSolver.java Mon Mar 11 15:45:54 2013
@@ -63,8 +63,7 @@ public abstract class AbstractDifferenti
*
* @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 {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/AbstractUnivariateDifferentiableSolver.java Mon Mar 11 15:45:54 2013
@@ -19,6 +19,7 @@ package org.apache.commons.math3.analysi
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 AbstractUnivariate
*
* @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));
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseAbstractUnivariateSolver.java Mon Mar 11 15:45:54 2013
@@ -166,11 +166,13 @@ public abstract class BaseAbstractUnivar
* @param max Upper bound for the interval.
* @param startValue Start value to use.
* @param maxEval Maximum number of evaluations.
+ * @exception NullArgumentException if f is null
*/
protected void setup(int maxEval,
FUNC f,
double min, double max,
- double startValue) {
+ double startValue)
+ throws NullArgumentException {
// Checks.
MathUtils.checkNotNull(f);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolver.java Mon Mar 11 15:45:54 2013
@@ -133,8 +133,7 @@ public abstract class BaseSecantSolver
*/
@Override
protected final double doSolve()
- throws ConvergenceException,
- MathInternalError {
+ throws ConvergenceException {
// Get initial solution
double x0 = getMin();
double x1 = getMax();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseUnivariateSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseUnivariateSolver.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseUnivariateSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/solvers/BaseUnivariateSolver.java Mon Mar 11 15:45:54 2013
@@ -17,6 +17,8 @@
package org.apache.commons.math3.analysis.solvers;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.TooManyEvaluationsException;
/**
@@ -97,12 +99,13 @@ public interface BaseUnivariateSolver<FU
* @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<FU
* @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}.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java Mon Mar 11 15:45:54 2013
@@ -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;
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java?rev=1455194&r1=1455193&r2=1455194&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/MathArrays.java Mon Mar 11 15:45:54 2013
@@ -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);
}