Class GaussIntegrator
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.integration.gauss.GaussIntegrator
-
- Direct Known Subclasses:
SymmetricGaussIntegrator
public class GaussIntegrator extends Object
Class that implements the Gaussian rule forintegratinga weighted function.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description GaussIntegrator(double[] points, double[] weights)Creates an integrator from the givenpointsandweights.GaussIntegrator(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 intgetNumberOfPoints()doublegetPoint(int index)Gets the integration point at the given index.doublegetWeight(int index)Gets the weight of the integration point at the given index.doubleintegrate(UnivariateFunction f)Returns an estimate of the integral off(x) * w(x), wherewis a weight function that depends on the actual flavor of the Gauss integration scheme.
-
-
-
Constructor Detail
-
GaussIntegrator
public GaussIntegrator(double[] points, double[] weights)
Creates an integrator from the givenpointsandweights. The integration interval is defined by the first and last value ofpointswhich must be sorted in increasing order.- Parameters:
points- Integration points.weights- Weights of the corresponding integration nodes.- Throws:
NonMonotonicSequenceException- if thepointsare not sorted in increasing order.DimensionMismatchException- if points and weights don't have the same length
-
GaussIntegrator
public GaussIntegrator(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 thepointsare not sorted in increasing order.- See Also:
GaussIntegrator(double[], double[])
-
-
Method Detail
-
integrate
public double integrate(UnivariateFunction f)
Returns an estimate of the integral off(x) * w(x), wherewis 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.- Parameters:
f- Function to integrate.- Returns:
- the integral of the weighted function.
-
getNumberOfPoints
public int getNumberOfPoints()
- Returns:
- the order of the integration rule (the number of integration points).
-
getPoint
public double getPoint(int index)
Gets the integration point at the given index. The index must be in the valid range but no check is performed.- Parameters:
index- index of the integration point- Returns:
- the integration point.
-
getWeight
public double getWeight(int index)
Gets the weight of the integration point at the given index. The index must be in the valid range but no check is performed.- Parameters:
index- index of the integration point- Returns:
- the weight.
-
-