Class IterativeLegendreGaussIntegrator
- java.lang.Object
-
- org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
-
- org.apache.commons.math3.analysis.integration.IterativeLegendreGaussIntegrator
-
- All Implemented Interfaces:
UnivariateIntegrator
public class IterativeLegendreGaussIntegrator extends BaseAbstractUnivariateIntegrator
This algorithm divides the integration interval into equally-sized sub-interval and on each of them performs a Legendre-Gauss quadrature. Because of its non-adaptive nature, this algorithm can converge to a wrong value for the integral (for example, if the function is significantly different from zero toward the ends of the integration interval). In particular, a change of variables aimed at estimating integrals over infinite intervals as proposed here should be avoided when using this class.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description private static GaussIntegratorFactory
FACTORY
Factory that computes the points and weights.private int
numberOfPoints
Number of integration points (per interval).-
Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations
-
-
Constructor Summary
Constructors Constructor Description IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy)
Builds an integrator with given accuracies.IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)
Builds an integrator with given accuracies and iterations counts.IterativeLegendreGaussIntegrator(int n, int minimalIterationCount, int maximalIterationCount)
Builds an integrator with given iteration counts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
doIntegrate()
Method for implementing actual integration algorithms in derived classes.private double
stage(int n)
Compute the n-th stage integral.-
Methods inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup
-
-
-
-
Field Detail
-
FACTORY
private static final GaussIntegratorFactory FACTORY
Factory that computes the points and weights.
-
numberOfPoints
private final int numberOfPoints
Number of integration points (per interval).
-
-
Constructor Detail
-
IterativeLegendreGaussIntegrator
public IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount) throws NotStrictlyPositiveException, NumberIsTooSmallException
Builds an integrator with given accuracies and iterations counts.- Parameters:
n
- Number of integration points.relativeAccuracy
- Relative accuracy of the result.absoluteAccuracy
- Absolute accuracy of the result.minimalIterationCount
- Minimum number of iterations.maximalIterationCount
- Maximum number of iterations.- Throws:
NotStrictlyPositiveException
- if minimal number of iterations or number of points are not strictly positive.NumberIsTooSmallException
- if maximal number of iterations is smaller than or equal to the minimal number of iterations.
-
IterativeLegendreGaussIntegrator
public IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy) throws NotStrictlyPositiveException
Builds an integrator with given accuracies.- Parameters:
n
- Number of integration points.relativeAccuracy
- Relative accuracy of the result.absoluteAccuracy
- Absolute accuracy of the result.- Throws:
NotStrictlyPositiveException
- ifn < 1
.
-
IterativeLegendreGaussIntegrator
public IterativeLegendreGaussIntegrator(int n, int minimalIterationCount, int maximalIterationCount) throws NotStrictlyPositiveException, NumberIsTooSmallException
Builds an integrator with given iteration counts.- Parameters:
n
- Number of integration points.minimalIterationCount
- Minimum number of iterations.maximalIterationCount
- Maximum number of iterations.- Throws:
NotStrictlyPositiveException
- if minimal number of iterations is not strictly positive.NumberIsTooSmallException
- if maximal number of iterations is smaller than or equal to the minimal number of iterations.NotStrictlyPositiveException
- ifn < 1
.
-
-
Method Detail
-
doIntegrate
protected double doIntegrate() throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException
Method for implementing actual integration algorithms in derived classes.- Specified by:
doIntegrate
in classBaseAbstractUnivariateIntegrator
- Returns:
- the root.
- Throws:
TooManyEvaluationsException
- if the maximal number of evaluations is exceeded.MaxCountExceededException
- if the maximum iteration count is exceeded or the integrator detects convergence problems otherwiseMathIllegalArgumentException
-
stage
private double stage(int n) throws TooManyEvaluationsException
Compute the n-th stage integral.- Parameters:
n
- Number of steps.- Returns:
- the value of n-th stage integral.
- Throws:
TooManyEvaluationsException
- if the maximum number of evaluations is exceeded.
-
-