de.torstennahm.integrate.quadratureformula
Class AbstractCachedGenerator

java.lang.Object
  extended by de.torstennahm.integrate.quadratureformula.AbstractCachedGenerator
All Implemented Interfaces:
Generator
Direct Known Subclasses:
ClenshawCurtis, DeltaGenerator, GaussHermite, GaussianWrapper, GaussLegendre, OpenTrapezoidal, Patterson, Trapezoidal

public abstract class AbstractCachedGenerator
extends java.lang.Object
implements Generator

Provides functionality for caching and retrieving quadrature formulas.

Since quadrature formulas are immutable, they can be returned from a cache and need only be calculated once.

According to general Generator contract, this class is thread-safe.

Author:
Torsten Nahm

Field Summary
protected  java.util.Map<java.lang.Integer,QuadratureFormula> levelCache
           
protected  java.util.Map<java.lang.Integer,QuadratureFormula> weightsCache
           
 
Constructor Summary
AbstractCachedGenerator()
           
 
Method Summary
protected abstract  QuadratureFormula generateByLevel(int level)
           
protected abstract  QuadratureFormula generateByNodes(int nodesRequested)
           
 QuadratureFormula getByLevel(int level)
          This routine is similar to getByLevel, but here the argument is only an abstract measure of the number of node-and-weight-pairs returned.
 QuadratureFormula getByNodes(int nodesRequested)
          Returns a set of node-and-weight pairs in an QuadratureFormula object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.torstennahm.integrate.quadratureformula.Generator
maxLevel, maxNodes
 

Field Detail

weightsCache

protected java.util.Map<java.lang.Integer,QuadratureFormula> weightsCache

levelCache

protected java.util.Map<java.lang.Integer,QuadratureFormula> levelCache
Constructor Detail

AbstractCachedGenerator

public AbstractCachedGenerator()
Method Detail

generateByNodes

protected abstract QuadratureFormula generateByNodes(int nodesRequested)

generateByLevel

protected abstract QuadratureFormula generateByLevel(int level)

getByNodes

public QuadratureFormula getByNodes(int nodesRequested)
Description copied from interface: Generator
Returns a set of node-and-weight pairs in an QuadratureFormula object. The number of nodes returned should be the same as those requested. If this is not possible due to the special structure of the generator, the number of nodes returned must be larger than that requested. However, when 1 node is requested exactly 1 pair must be returned.

The number of nodes requested must be between 1 and getMaxNodes().

Specified by:
getByNodes in interface Generator
Parameters:
nodesRequested - number of nodes for the quadrature formula
Returns:
quadrature formula

getByLevel

public QuadratureFormula getByLevel(int level)
Description copied from interface: Generator
This routine is similar to getByLevel, but here the argument is only an abstract measure of the number of node-and-weight-pairs returned. In general, the number of weights should rise exponentially with the level. However, the only conditions imposed it that the number of pairs should rise strictly monotonously with the level. level must be between 0 and getMaxLevel().

In the special case where level is requested as 0, a quadrature formula with exactly 1 pair must be returned.

Specified by:
getByLevel in interface Generator
Parameters:
level - level of the quadrature formula
Returns:
quadrature formula