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 the computeRule method.
Since:
2.0
  • Constructor Details

    • AbstractRuleFactory

      public AbstractRuleFactory()
      Empty constructor.

      This constructor is not strictly necessary, but it prevents spurious javadoc warnings with JDK 18 and later.

      Since:
      3.0
  • Method Details

    • 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 interface RuleFactory
      Parameters:
      numberOfPoints - Number of integration points.
      Returns:
      a copy of the integration rule.
      Throws:
      MathIllegalArgumentException - if numberOfPoints < 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 for
      ratioEvaluator - 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