de.torstennahm.integrate.quadratureformula
Class QuadratureFormula

java.lang.Object
  extended by de.torstennahm.integrate.quadratureformula.QuadratureFormula

public class QuadratureFormula
extends java.lang.Object

This class represents a quadrature formula, given by a list of nodes and weights. The nodes are sorted in ascending order, so lower indices correspond to numerically smaller nodes.

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

Author:
Torsten Nahm

Constructor Summary
QuadratureFormula(double[] nodes, double[] weights)
          Constructs the quadrature formula from arrays.
QuadratureFormula(java.util.List<java.lang.Double> nodeList, java.util.List<java.lang.Double> weightList)
          Constructs the quadrature formula from lists of Doubles.
 
Method Summary
 double getNode(int index)
          Returns the node of the specified (node, weight) pair.
 double[] getNodesArray()
          Returns the nodes as an array.
 int getSize()
          Returns number of (node, weight) pairs of the formula.
 double getWeight(int index)
          Returns the weight of the specified (node, weight) pair.
 double[] getWeightsArray()
          Returns the weights as an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadratureFormula

public QuadratureFormula(double[] nodes,
                         double[] weights)
Constructs the quadrature formula from arrays. The array of nodes must be sorted in ascending order.

Parameters:
nodes - array of nodes
weights - array of weights
Throws:
java.lang.IllegalArgumentException - if the arrays have different lengths
java.lang.IllegalArgumentException - if the nodes are not sorted

QuadratureFormula

public QuadratureFormula(java.util.List<java.lang.Double> nodeList,
                         java.util.List<java.lang.Double> weightList)
Constructs the quadrature formula from lists of Doubles. The list of nodes must be sorted in ascending order.

Parameters:
nodeList - list of nodes
weightList - list of weights
Throws:
java.lang.IllegalArgumentException - if the lists have different lengths
java.lang.IllegalArgumentException - if the nodes are not sorted
Method Detail

getSize

public int getSize()
Returns number of (node, weight) pairs of the formula.

Returns:
number of nodes in the forumla

getNode

public double getNode(int index)
Returns the node of the specified (node, weight) pair.

Parameters:
index - of the pair
Returns:
node with the given index

getWeight

public double getWeight(int index)
Returns the weight of the specified (node, weight) pair.

Parameters:
index - of the pair
Returns:
weight with the given index

getNodesArray

public double[] getNodesArray()
Returns the nodes as an array.

Returns:
nodes array

getWeightsArray

public double[] getWeightsArray()
Returns the weights as an array.

Returns:
weights array