org.apache.commons.math3.analysis.integration.gauss

## Class BaseRuleFactory<T extends java.lang.Number>

- java.lang.Object
- - org.apache.commons.math3.analysis.integration.gauss.BaseRuleFactory<T>

- Type Parameters:
    `T` - Type of the number used to represent the points and weights of the quadrature rules.
  Direct Known Subclasses:
    LegendreHighPrecisionRuleFactory, LegendreRuleFactory

      public abstract class BaseRuleFactory<T extends java.lang.Number>
      extends java.lang.Object

  Base class for rules that determines the integration nodes and their weights. Subclasses must implement the `computeRule` method.
  Since:
    3.1
  Version:
    $Id: BaseRuleFactory.java 1382197 2012-09-07 22:35:01Z erans $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.util.Map<java.lang.Integer,Pair<T[],T[]>>` | `pointsAndWeights` List of points and weights, indexed by the order of the rule.
    `private java.util.Map<java.lang.Integer,Pair<double[],double[]>>` | `pointsAndWeightsDouble` Cache for double-precision rules.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseRuleFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addRule(Pair<T[],T[]> rule)` Stores a rule.
    `protected abstract Pair<T[],T[]>` | `computeRule(int numberOfPoints)` Computes the rule for the given order.
    `private static <T extends java.lang.Number> Pair<double[],double[]>` | `convertToDouble(Pair<T[],T[]> rule)` Converts the from the actual `Number` type to `double`
    `Pair<double[],double[]>` | `getRule(int numberOfPoints)` Gets a copy of the quadrature rule with the given number of integration points.
    `protected Pair<T[],T[]>` | `getRuleInternal(int numberOfPoints)` Gets a rule.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### pointsAndWeights

          private final java.util.Map<java.lang.Integer,Pair<T extends java.lang.Number[],T extends java.lang.Number[]>> pointsAndWeights

      List of points and weights, indexed by the order of the rule.

    - #### pointsAndWeightsDouble

          private final java.util.Map<java.lang.Integer,Pair<double[],double[]>> pointsAndWeightsDouble

      Cache for double-precision rules.

  - ### Constructor Detail

    - #### BaseRuleFactory

          public BaseRuleFactory()

  - ### Method Detail

    - #### getRule

          public Pair<double[],double[]> getRule(int numberOfPoints)
                                          throws NotStrictlyPositiveException

      Gets a copy of the quadrature rule with the given number of integration points.
      Parameters:
        `numberOfPoints` - Number of integration points.
      Returns:
        a copy of the integration rule.
      Throws:
        `NotStrictlyPositiveException` - if `numberOfPoints < 1`.

    - #### getRuleInternal

          protected Pair<T[],T[]> getRuleInternal(int numberOfPoints)
                                                                                             throws NotStrictlyPositiveException

      Gets a rule. Synchronization ensures that rules will be computed and added to the cache at most once. The returned rule is a reference into the cache.
      Parameters:
        `numberOfPoints` - Order of the rule to be retrieved.
      Returns:
        the points and weights corresponding to the given order.
      Throws:
        `NotStrictlyPositiveException` - if `numberOfPoints < 1`.

    - #### addRule

          protected void addRule(Pair<T[],T[]> rule)

      Stores a rule.
      Parameters:
        `rule` - Rule to be stored.
      Throws:
        `DimensionMismatchException` - if the elements of the pair do not have the same length.

    - #### computeRule

          protected abstract Pair<T[],T[]> computeRule(int numberOfPoints)

      Computes the rule for the given order.
      Parameters:
        `numberOfPoints` - Order of the rule to be computed.
      Returns:
        the computed rule.

    - #### convertToDouble

          private static <T extends java.lang.Number> Pair<double[],double[]> convertToDouble(Pair<T[],T[]> rule)

      Converts the from the actual `Number` type to `double`
      Type Parameters:
        `T` - Type of the number used to represent the points and weights of the quadrature rules.
      Parameters:
        `rule` - Points and weights.
      Returns:
        points and weights as `double`s.

Copyright (c) 2003-2013 Apache Software Foundation