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 Summary Link icon

    Constructors
    Modifier
    Constructor
    Description
    protected
    Empty constructor.
  • Method Summary Link icon

    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.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • AbstractRuleFactory Link icon

      protected 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 Link icon

    • getRule Link icon

      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.
      MathIllegalArgumentException - if numberOfPoints > 1000.
      MathIllegalArgumentException - if the elements of the rule pair do not have the same length.
    • computeRule Link icon

      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 Link icon

      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 Link icon

      protected void enforceSymmetry(double[] roots)
      Enforce symmetry of roots.
      Parameters:
      roots - roots to process in place