Class GaussIntegratorFactory
- java.lang.Object
-
- org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory
-
public class GaussIntegratorFactory extends java.lang.Object
Class that provides different ways to compute the nodes and weights to be used by theGaussian integration rule
.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description private BaseRuleFactory<java.lang.Double>
hermite
Generator of Gauss-Hermite integrators.private BaseRuleFactory<java.lang.Double>
legendre
Generator of Gauss-Legendre integrators.private BaseRuleFactory<java.math.BigDecimal>
legendreHighPrecision
Generator of Gauss-Legendre integrators.
-
Constructor Summary
Constructors Constructor Description GaussIntegratorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Pair<double[],double[]>
getRule(BaseRuleFactory<? extends java.lang.Number> factory, int numberOfPoints)
SymmetricGaussIntegrator
hermite(int numberOfPoints)
Creates a Gauss-Hermite integrator of the given order.GaussIntegrator
legendre(int numberOfPoints)
Creates a Gauss-Legendre integrator of the given order.GaussIntegrator
legendre(int numberOfPoints, double lowerBound, double upperBound)
Creates a Gauss-Legendre integrator of the given order.GaussIntegrator
legendreHighPrecision(int numberOfPoints)
Creates a Gauss-Legendre integrator of the given order.GaussIntegrator
legendreHighPrecision(int numberOfPoints, double lowerBound, double upperBound)
Creates an integrator of the given order, and whose call to theintegrate
method will perform an integration on the given interval.private static Pair<double[],double[]>
transform(Pair<double[],double[]> rule, double a, double b)
Performs a change of variable so that the integration can be performed on an arbitrary interval[a, b]
.
-
-
-
Field Detail
-
legendre
private final BaseRuleFactory<java.lang.Double> legendre
Generator of Gauss-Legendre integrators.
-
legendreHighPrecision
private final BaseRuleFactory<java.math.BigDecimal> legendreHighPrecision
Generator of Gauss-Legendre integrators.
-
hermite
private final BaseRuleFactory<java.lang.Double> hermite
Generator of Gauss-Hermite integrators.
-
-
Method Detail
-
legendre
public GaussIntegrator legendre(int numberOfPoints)
Creates a Gauss-Legendre integrator of the given order. The call to theintegrate
method will perform an integration on the natural interval[-1 , 1]
.- Parameters:
numberOfPoints
- Order of the integration rule.- Returns:
- a Gauss-Legendre integrator.
-
legendre
public GaussIntegrator legendre(int numberOfPoints, double lowerBound, double upperBound) throws NotStrictlyPositiveException
Creates a Gauss-Legendre integrator of the given order. The call to theintegrate
method will perform an integration on the given interval.- Parameters:
numberOfPoints
- Order of the integration rule.lowerBound
- Lower bound of the integration interval.upperBound
- Upper bound of the integration interval.- Returns:
- a Gauss-Legendre integrator.
- Throws:
NotStrictlyPositiveException
- if number of points is not positive
-
legendreHighPrecision
public GaussIntegrator legendreHighPrecision(int numberOfPoints) throws NotStrictlyPositiveException
Creates a Gauss-Legendre integrator of the given order. The call to theintegrate
method will perform an integration on the natural interval[-1 , 1]
.- Parameters:
numberOfPoints
- Order of the integration rule.- Returns:
- a Gauss-Legendre integrator.
- Throws:
NotStrictlyPositiveException
- if number of points is not positive
-
legendreHighPrecision
public GaussIntegrator legendreHighPrecision(int numberOfPoints, double lowerBound, double upperBound) throws NotStrictlyPositiveException
Creates an integrator of the given order, and whose call to theintegrate
method will perform an integration on the given interval.- Parameters:
numberOfPoints
- Order of the integration rule.lowerBound
- Lower bound of the integration interval.upperBound
- Upper bound of the integration interval.- Returns:
- a Gauss-Legendre integrator.
- Throws:
NotStrictlyPositiveException
- if number of points is not positive
-
hermite
public SymmetricGaussIntegrator hermite(int numberOfPoints)
Creates a Gauss-Hermite integrator of the given order. The call to theintegrate
method will perform a weighted integration on the interval \([-\infty, +\infty]\): the computed value is the improper integral of \(e^{-x^2}f(x)\) where \(f(x)\) is the function passed to theintegrate
method.- Parameters:
numberOfPoints
- Order of the integration rule.- Returns:
- a Gauss-Hermite integrator.
-
getRule
private static Pair<double[],double[]> getRule(BaseRuleFactory<? extends java.lang.Number> factory, int numberOfPoints) throws NotStrictlyPositiveException, DimensionMismatchException
- Parameters:
factory
- Integration rule factory.numberOfPoints
- Order of the integration rule.- Returns:
- the integration nodes and weights.
- Throws:
NotStrictlyPositiveException
- if number of points is not positiveDimensionMismatchException
- if the elements of the rule pair do not have the same length.
-
transform
private static Pair<double[],double[]> transform(Pair<double[],double[]> rule, double a, double b)
Performs a change of variable so that the integration can be performed on an arbitrary interval[a, b]
. It is assumed that the natural interval is[-1, 1]
.- Parameters:
rule
- Original points and weights.a
- Lower bound of the integration interval.b
- Lower bound of the integration interval.- Returns:
- the points and weights adapted to the new interval.
-
-