Class SymmetricGaussIntegrator
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.integration.gauss.GaussIntegrator
-
- org.apache.commons.math4.legacy.analysis.integration.gauss.SymmetricGaussIntegrator
-
public class SymmetricGaussIntegrator extends GaussIntegrator
This class's implementsintegrate
method assuming that the integral is symmetric about 0. This allows to reduce numerical errors.- Since:
- 3.3
-
-
Constructor Summary
Constructors Constructor Description SymmetricGaussIntegrator(double[] points, double[] weights)
Creates an integrator from the givenpoints
andweights
.SymmetricGaussIntegrator(Pair<double[],double[]> pointsAndWeights)
Creates an integrator from the given pair of points (first element of the pair) and weights (second element of the pair.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
integrate(UnivariateFunction f)
Returns an estimate of the integral off(x) * w(x)
, wherew
is a weight function that depends on the actual flavor of the Gauss integration scheme.-
Methods inherited from class org.apache.commons.math4.legacy.analysis.integration.gauss.GaussIntegrator
getNumberOfPoints, getPoint, getWeight
-
-
-
-
Constructor Detail
-
SymmetricGaussIntegrator
public SymmetricGaussIntegrator(double[] points, double[] weights)
Creates an integrator from the givenpoints
andweights
. The integration interval is defined by the first and last value ofpoints
which must be sorted in increasing order.- Parameters:
points
- Integration points.weights
- Weights of the corresponding integration nodes.- Throws:
NonMonotonicSequenceException
- if thepoints
are not sorted in increasing order.DimensionMismatchException
- if points and weights don't have the same length
-
SymmetricGaussIntegrator
public SymmetricGaussIntegrator(Pair<double[],double[]> pointsAndWeights)
Creates an integrator from the given pair of points (first element of the pair) and weights (second element of the pair.- Parameters:
pointsAndWeights
- Integration points and corresponding weights.- Throws:
NonMonotonicSequenceException
- if thepoints
are not sorted in increasing order.- See Also:
SymmetricGaussIntegrator(double[], double[])
-
-
Method Detail
-
integrate
public double integrate(UnivariateFunction f)
Returns an estimate of the integral off(x) * w(x)
, wherew
is a weight function that depends on the actual flavor of the Gauss integration scheme. The algorithm uses the points and associated weights, as passed to theconstructor
.- Overrides:
integrate
in classGaussIntegrator
- Parameters:
f
- Function to integrate.- Returns:
- the integral of the weighted function.
-
-