From 47deeb3528511e02c6f5e52ba0aa0c917b9fd670 Mon Sep 17 00:00:00 2001 From: abchaubey Date: Mon, 21 Dec 2020 23:02:58 +0800 Subject: [PATCH 1/3] MATH-1566: Fix CheckStyle Issues --- .../analysis/integration/MidPointIntegrator.java | 15 --------------- .../analysis/integration/RombergIntegrator.java | 12 ------------ .../analysis/integration/SimpsonIntegrator.java | 10 ---------- .../analysis/integration/TrapezoidIntegrator.java | 15 --------------- .../integration/UnivariateIntegrator.java | 11 ----------- .../integration/gauss/GaussIntegrator.java | 5 ----- .../integration/gauss/GaussIntegratorFactory.java | 12 ++---------- .../integration/gauss/HermiteRuleFactory.java | 1 - .../integration/gauss/LaguerreRuleFactory.java | 5 ++--- .../gauss/LegendreHighPrecisionRuleFactory.java | 5 ++--- .../integration/gauss/LegendreRuleFactory.java | 1 - .../gauss/SymmetricGaussIntegrator.java | 7 ------- 12 files changed, 6 insertions(+), 93 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java index d010fbd133..df457cfb5d 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java @@ -16,12 +16,7 @@ */ package org.apache.commons.math4.analysis.integration; -import org.apache.commons.math4.exception.MathIllegalArgumentException; -import org.apache.commons.math4.exception.MaxCountExceededException; -import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.NumberIsTooLargeException; -import org.apache.commons.math4.exception.NumberIsTooSmallException; -import org.apache.commons.math4.exception.TooManyEvaluationsException; import org.apache.commons.math4.util.FastMath; /** @@ -47,10 +42,6 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator { * @param absoluteAccuracy absolute accuracy of the result * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 39. */ @@ -69,10 +60,6 @@ public MidPointIntegrator(final double relativeAccuracy, * Build a midpoint integrator with given iteration counts. * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 39. */ @@ -109,8 +96,6 @@ public MidPointIntegrator() { * @param diffMaxMin Difference between the lower bound and upper bound * of the integration interval. * @return the value of n-th stage integral - * @throws TooManyEvaluationsException if the maximal number of evaluations - * is exceeded. */ private double stage(final int n, double previousStageResult, diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java index 50179dff62..e5a9f4378a 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java @@ -16,11 +16,7 @@ */ package org.apache.commons.math4.analysis.integration; -import org.apache.commons.math4.exception.MaxCountExceededException; -import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.NumberIsTooLargeException; -import org.apache.commons.math4.exception.NumberIsTooSmallException; -import org.apache.commons.math4.exception.TooManyEvaluationsException; import org.apache.commons.math4.util.FastMath; /** @@ -47,10 +43,6 @@ public class RombergIntegrator extends BaseAbstractUnivariateIntegrator { * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT}) - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT} */ @@ -70,10 +62,6 @@ public RombergIntegrator(final double relativeAccuracy, * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT}) - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT} */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java index 554be7548e..dc9fcbe519 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java @@ -16,9 +16,7 @@ */ package org.apache.commons.math4.analysis.integration; -import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.NumberIsTooLargeException; -import org.apache.commons.math4.exception.NumberIsTooSmallException; import org.apache.commons.math4.util.FastMath; /** @@ -44,10 +42,6 @@ public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator { * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT}) - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT} */ @@ -67,10 +61,6 @@ public SimpsonIntegrator(final double relativeAccuracy, * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT}) - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT} */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java index 5a7e0e88f7..b812280cb6 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java @@ -16,12 +16,7 @@ */ package org.apache.commons.math4.analysis.integration; -import org.apache.commons.math4.exception.MathIllegalArgumentException; -import org.apache.commons.math4.exception.MaxCountExceededException; -import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.exception.NumberIsTooLargeException; -import org.apache.commons.math4.exception.NumberIsTooSmallException; -import org.apache.commons.math4.exception.TooManyEvaluationsException; import org.apache.commons.math4.util.FastMath; /** @@ -48,10 +43,6 @@ public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator { * @param absoluteAccuracy absolute accuracy of the result * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 63. */ @@ -70,10 +61,6 @@ public TrapezoidIntegrator(final double relativeAccuracy, * Build a trapezoid integrator with given iteration counts. * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations - * @exception NotStrictlyPositiveException if minimal number of iterations - * is not strictly positive - * @exception NumberIsTooSmallException if maximal number of iterations - * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 63. */ @@ -106,8 +93,6 @@ public TrapezoidIntegrator() { * @param baseIntegrator integrator holding integration parameters * @param n the stage of 1/2 refinement, n = 0 is no refinement * @return the value of n-th stage integral - * @throws TooManyEvaluationsException if the maximal number of evaluations - * is exceeded. */ double stage(final BaseAbstractUnivariateIntegrator baseIntegrator, final int n) { if (n == 0) { diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java index 994985cea6..e045542e64 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java @@ -17,10 +17,6 @@ package org.apache.commons.math4.analysis.integration; import org.apache.commons.math4.analysis.UnivariateFunction; -import org.apache.commons.math4.exception.MathIllegalArgumentException; -import org.apache.commons.math4.exception.MaxCountExceededException; -import org.apache.commons.math4.exception.NullArgumentException; -import org.apache.commons.math4.exception.TooManyEvaluationsException; /** * Interface for univariate real integration algorithms. @@ -65,13 +61,6 @@ public interface UnivariateIntegrator { * @param min the lower bound for the interval * @param max the upper bound for the interval * @return the value of integral - * @throws TooManyEvaluationsException if the maximum number of function - * evaluations is exceeded - * @throws MaxCountExceededException if the maximum iteration count is exceeded - * or the integrator detects convergence problems otherwise - * @throws MathIllegalArgumentException if {@code min > max} or the endpoints do not - * satisfy the requirements specified by the integrator - * @throws NullArgumentException if {@code f} is {@code null}. */ double integrate(int maxEval, UnivariateFunction f, double min, double max); diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java index de86f486d3..995259d950 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java @@ -18,7 +18,6 @@ import org.apache.commons.math4.analysis.UnivariateFunction; import org.apache.commons.math4.exception.DimensionMismatchException; -import org.apache.commons.math4.exception.NonMonotonicSequenceException; import org.apache.commons.math4.util.MathArrays; import org.apache.commons.math4.util.Pair; @@ -42,8 +41,6 @@ public class GaussIntegrator { * * @param points Integration points. * @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, @@ -64,8 +61,6 @@ public GaussIntegrator(double[] points, * the pair) and weights (second element of the pair. * * @param pointsAndWeights Integration points and corresponding weights. - * @throws NonMonotonicSequenceException if the {@code points} are not - * sorted in increasing order. * * @see #GaussIntegrator(double[], double[]) */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java index 3b1c2eb995..47e10b53bf 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java @@ -16,12 +16,10 @@ */ package org.apache.commons.math4.analysis.integration.gauss; -import java.math.BigDecimal; - -import org.apache.commons.math4.exception.DimensionMismatchException; -import org.apache.commons.math4.exception.NotStrictlyPositiveException; import org.apache.commons.math4.util.Pair; +import java.math.BigDecimal; + /** * Class that provides different ways to compute the nodes and weights to be * used by the {@link GaussIntegrator Gaussian integration rule}. @@ -81,7 +79,6 @@ public GaussIntegrator legendre(int numberOfPoints) { * @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, @@ -99,7 +96,6 @@ public GaussIntegrator legendre(int numberOfPoints, * * @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) { return new GaussIntegrator(getRule(legendreHighPrecision, numberOfPoints)); @@ -114,7 +110,6 @@ public GaussIntegrator legendreHighPrecision(int numberOfPoints) { * @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, @@ -145,9 +140,6 @@ public SymmetricGaussIntegrator hermite(int numberOfPoints) { * @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 getRule(BaseRuleFactory factory, int numberOfPoints) { diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java index c680ed92a4..2d5a3e1a95 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java @@ -16,7 +16,6 @@ */ package org.apache.commons.math4.analysis.integration.gauss; -import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.Pair; diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java index fc9eb3b899..ee7969a3d9 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java @@ -16,16 +16,15 @@ */ package org.apache.commons.math4.analysis.integration.gauss; -import java.util.Arrays; - import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; import org.apache.commons.math4.analysis.polynomials.PolynomialsUtils; -import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.linear.EigenDecomposition; import org.apache.commons.math4.linear.MatrixUtils; import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.util.Pair; +import java.util.Arrays; + /** * Factory that creates Gauss-type quadrature rule using Laguerre polynomials. * diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java index 811f6d1c65..a982deb0e7 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java @@ -16,12 +16,11 @@ */ package org.apache.commons.math4.analysis.integration.gauss; +import org.apache.commons.math4.util.Pair; + import java.math.BigDecimal; import java.math.MathContext; -import org.apache.commons.math4.exception.DimensionMismatchException; -import org.apache.commons.math4.util.Pair; - /** * Factory that creates Gauss-type quadrature rule using Legendre polynomials. * In this implementation, the lower and upper bounds of the natural interval diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java index 657f594ae9..cbc1e7d9b0 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java @@ -16,7 +16,6 @@ */ package org.apache.commons.math4.analysis.integration.gauss; -import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.util.Pair; /** diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java index 083b8483bd..7210b4742a 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java @@ -17,8 +17,6 @@ package org.apache.commons.math4.analysis.integration.gauss; import org.apache.commons.math4.analysis.UnivariateFunction; -import org.apache.commons.math4.exception.DimensionMismatchException; -import org.apache.commons.math4.exception.NonMonotonicSequenceException; import org.apache.commons.math4.util.Pair; /** @@ -36,9 +34,6 @@ public class SymmetricGaussIntegrator extends GaussIntegrator { * * @param points Integration points. * @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 SymmetricGaussIntegrator(double[] points, double[] weights) { @@ -50,8 +45,6 @@ public SymmetricGaussIntegrator(double[] points, * the pair) and weights (second element of the pair. * * @param pointsAndWeights Integration points and corresponding weights. - * @throws NonMonotonicSequenceException if the {@code points} are not - * sorted in increasing order. * * @see #SymmetricGaussIntegrator(double[], double[]) */ From 91d57beefb72fa0cfd42490c47f6ecdc127945b8 Mon Sep 17 00:00:00 2001 From: abchaubey Date: Mon, 21 Dec 2020 23:04:48 +0800 Subject: [PATCH 2/3] MATH-1566: Fix CheckStyle Issues --- .../math4/analysis/integration/gauss/LaguerreRuleFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java index ee7969a3d9..23e45df123 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java @@ -16,6 +16,8 @@ */ package org.apache.commons.math4.analysis.integration.gauss; +import java.util.Arrays; + import org.apache.commons.math4.analysis.polynomials.PolynomialFunction; import org.apache.commons.math4.analysis.polynomials.PolynomialsUtils; import org.apache.commons.math4.linear.EigenDecomposition; @@ -23,8 +25,6 @@ import org.apache.commons.math4.linear.RealMatrix; import org.apache.commons.math4.util.Pair; -import java.util.Arrays; - /** * Factory that creates Gauss-type quadrature rule using Laguerre polynomials. * From 94f7208c1f38d8b4f923eadcb6ab754b2326f5dd Mon Sep 17 00:00:00 2001 From: abchaubey Date: Tue, 22 Dec 2020 07:53:35 +0800 Subject: [PATCH 3/3] MATH-1566: updated as per review comments --- .../math4/analysis/integration/MidPointIntegrator.java | 10 ++++++++++ .../math4/analysis/integration/RombergIntegrator.java | 8 ++++++++ .../math4/analysis/integration/SimpsonIntegrator.java | 8 ++++++++ .../analysis/integration/TrapezoidIntegrator.java | 10 ++++++++++ .../analysis/integration/UnivariateIntegrator.java | 7 +++++++ .../analysis/integration/gauss/GaussIntegrator.java | 4 ++++ .../integration/gauss/GaussIntegratorFactory.java | 7 ++++++- .../integration/gauss/SymmetricGaussIntegrator.java | 5 +++++ 8 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java index df457cfb5d..757e92ddd2 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java @@ -42,6 +42,10 @@ public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator { * @param absoluteAccuracy absolute accuracy of the result * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 39. */ @@ -60,6 +64,10 @@ public MidPointIntegrator(final double relativeAccuracy, * Build a midpoint integrator with given iteration counts. * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 39. */ @@ -96,6 +104,8 @@ public MidPointIntegrator() { * @param diffMaxMin Difference between the lower bound and upper bound * of the integration interval. * @return the value of n-th stage integral + * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximal number of evaluations + * is exceeded. */ private double stage(final int n, double previousStageResult, diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java index e5a9f4378a..5e81c01b7b 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java @@ -43,6 +43,10 @@ public class RombergIntegrator extends BaseAbstractUnivariateIntegrator { * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT}) + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT} */ @@ -62,6 +66,10 @@ public RombergIntegrator(final double relativeAccuracy, * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT}) + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT} */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java index dc9fcbe519..0e85f72990 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java @@ -42,6 +42,10 @@ public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator { * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT}) + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT} */ @@ -61,6 +65,10 @@ public SimpsonIntegrator(final double relativeAccuracy, * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT}) + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT} */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java index b812280cb6..87239c7863 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java @@ -43,6 +43,10 @@ public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator { * @param absoluteAccuracy absolute accuracy of the result * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 63. */ @@ -61,6 +65,10 @@ public TrapezoidIntegrator(final double relativeAccuracy, * Build a trapezoid integrator with given iteration counts. * @param minimalIterationCount minimum number of iterations * @param maximalIterationCount maximum number of iterations + * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations + * is not strictly positive + * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations + * is lesser than or equal to the minimal number of iterations * @exception NumberIsTooLargeException if maximal number of iterations * is greater than 63. */ @@ -93,6 +101,8 @@ public TrapezoidIntegrator() { * @param baseIntegrator integrator holding integration parameters * @param n the stage of 1/2 refinement, n = 0 is no refinement * @return the value of n-th stage integral + * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximal number of evaluations + * is exceeded. */ double stage(final BaseAbstractUnivariateIntegrator baseIntegrator, final int n) { if (n == 0) { diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java index e045542e64..97dd416eae 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java @@ -61,6 +61,13 @@ public interface UnivariateIntegrator { * @param min the lower bound for the interval * @param max the upper bound for the interval * @return the value of integral + * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximum number of function + * evaluations is exceeded + * @throws org.apache.commons.math4.exception.MaxCountExceededException if the maximum iteration count is exceeded + * or the integrator detects convergence problems otherwise + * @throws org.apache.commons.math4.exception.MathIllegalArgumentException if {@code min > max} or the endpoints do not + * satisfy the requirements specified by the integrator + * @throws org.apache.commons.math4.exception.NullArgumentException if {@code f} is {@code null}. */ double integrate(int maxEval, UnivariateFunction f, double min, double max); diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java index 995259d950..9e0213a495 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java @@ -41,6 +41,8 @@ public class GaussIntegrator { * * @param points Integration points. * @param weights Weights of the corresponding integration nodes. + * @throws org.apache.commons.math4.exception.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, @@ -61,6 +63,8 @@ public GaussIntegrator(double[] points, * the pair) and weights (second element of the pair. * * @param pointsAndWeights Integration points and corresponding weights. + * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not + * sorted in increasing order. * * @see #GaussIntegrator(double[], double[]) */ diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java index 47e10b53bf..e65124cd10 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java @@ -17,7 +17,6 @@ package org.apache.commons.math4.analysis.integration.gauss; import org.apache.commons.math4.util.Pair; - import java.math.BigDecimal; /** @@ -79,6 +78,7 @@ public GaussIntegrator legendre(int numberOfPoints) { * @param lowerBound Lower bound of the integration interval. * @param upperBound Upper bound of the integration interval. * @return a Gauss-Legendre integrator. + * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive */ public GaussIntegrator legendre(int numberOfPoints, double lowerBound, @@ -96,6 +96,7 @@ public GaussIntegrator legendre(int numberOfPoints, * * @param numberOfPoints Order of the integration rule. * @return a Gauss-Legendre integrator. + * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive */ public GaussIntegrator legendreHighPrecision(int numberOfPoints) { return new GaussIntegrator(getRule(legendreHighPrecision, numberOfPoints)); @@ -110,6 +111,7 @@ public GaussIntegrator legendreHighPrecision(int numberOfPoints) { * @param lowerBound Lower bound of the integration interval. * @param upperBound Upper bound of the integration interval. * @return a Gauss-Legendre integrator. + * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive */ public GaussIntegrator legendreHighPrecision(int numberOfPoints, double lowerBound, @@ -140,6 +142,9 @@ public SymmetricGaussIntegrator hermite(int numberOfPoints) { * @param factory Integration rule factory. * @param numberOfPoints Order of the integration rule. * @return the integration nodes and weights. + * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive + * @throws org.apache.commons.math4.exception.DimensionMismatchException if the elements of the rule pair do not + * have the same length. */ private static Pair getRule(BaseRuleFactory factory, int numberOfPoints) { diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java index 7210b4742a..1230a1dc24 100644 --- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java +++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java @@ -34,6 +34,9 @@ public class SymmetricGaussIntegrator extends GaussIntegrator { * * @param points Integration points. * @param weights Weights of the corresponding integration nodes. + * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not + * sorted in increasing order. + * @throws org.apache.commons.math4.exception.DimensionMismatchException if points and weights don't have the same length */ public SymmetricGaussIntegrator(double[] points, double[] weights) { @@ -45,6 +48,8 @@ public SymmetricGaussIntegrator(double[] points, * the pair) and weights (second element of the pair. * * @param pointsAndWeights Integration points and corresponding weights. + * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not + * sorted in increasing order. * * @see #SymmetricGaussIntegrator(double[], double[]) */