Class AbstractRuleFactory
- java.lang.Object
-
- org.hipparchus.analysis.integration.gauss.AbstractRuleFactory
-
- All Implemented Interfaces:
RuleFactory
- Direct Known Subclasses:
ConvertingRuleFactory
,HermiteRuleFactory
,LaguerreRuleFactory
,LegendreRuleFactory
public abstract class AbstractRuleFactory extends Object implements RuleFactory
Base class for rules that determines the integration nodes and their weights. Subclasses must implement thecomputeRule
method.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractRuleFactory()
Empty constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Pair<double[],double[]>
computeRule(int numberOfPoints)
Computes the rule for the given order.protected void
enforceSymmetry(double[] roots)
Enforce symmetry of roots.protected double[]
findRoots(int n, UnivariateFunction ratioEvaluator)
Computes roots of the associated orthogonal polynomials.Pair<double[],double[]>
getRule(int numberOfPoints)
Gets a copy of the quadrature rule with the given number of integration points.
-
-
-
Method Detail
-
getRule
public Pair<double[],double[]> getRule(int numberOfPoints) throws MathIllegalArgumentException
Gets a copy of the quadrature rule with the given number of integration points. The number of points is arbitrarily limited to 1000. It prevents resources exhaustion. In practice the number of points is often much lower.- Specified by:
getRule
in interfaceRuleFactory
- Parameters:
numberOfPoints
- Number of integration points.- Returns:
- a copy of the integration rule.
- Throws:
MathIllegalArgumentException
- ifnumberOfPoints < 1
.
-
computeRule
protected abstract Pair<double[],double[]> computeRule(int numberOfPoints) throws MathIllegalArgumentException
Computes the rule for the given order.- Parameters:
numberOfPoints
- Order of the rule to be computed.- Returns:
- the computed rule.
- Throws:
MathIllegalArgumentException
- if the elements of the pair do not have the same length.
-
findRoots
protected double[] findRoots(int n, UnivariateFunction ratioEvaluator)
Computes roots of the associated orthogonal polynomials.The roots are found using the Aberth method. The guess points for initializing search for degree n are fixed for degrees 1 and 2 and are selected from n-1 roots of rule n-1 (the two extreme roots are used, plus the n-1 intermediate points between all roots).
- Parameters:
n
- number of roots to search forratioEvaluator
- function evaluating the ratio Pₙ(x)/Pₙ'(x)- Returns:
- sorted array of roots
-
enforceSymmetry
protected void enforceSymmetry(double[] roots)
Enforce symmetry of roots.- Parameters:
roots
- roots to process in place
-
-