vec_math
Interface Integrator

All Known Implementing Classes:
SimpleIntegrator

public interface Integrator

This interface defines calculus of numerical integration. It may be used in different ways. Either you can set a list of x/y values using the setData(double[], double[]) method, or you can start the integrator with initData(double, double) and then add values during the life-time of the integrator using the add(double, double) method. Calling getIntegral() returns the numerical integral over all values added. Limiting the integration borders can be done either by calling getIntegral() twice with different x-values, or by ereasing all previously added values with a call to initData(double, double).
For performance issues, the differentiator uses primitive data types instead of Double objects.


Method Summary
 void add(double y)
          Adds a new point to the data set, stating only a y value for an equally-spaced data set.
 void add(double x, double y)
          Adds a new point to the data set, stating both, the x and y value.
 double getIntegral()
          Calculates the numerical integral over the entire set.
 double getIntegral(double upper)
          Calculates the numerical integral from the start of the set up to the desired upper-boundary.
 void initData(double xfirst, double yfirst)
          Erases all previously added data points, starting a new data set.
 void setData(double[] y)
          Sets an equally-spaced y-data set.
 void setData(double[] x, double[] y)
          Sets an entire list of x/y data points.
 

Method Detail

setData

void setData(double[] x,
             double[] y)
Sets an entire list of x/y data points. If the x-list is null, y is expected to be an equally-spaced data set. Note that not necessarily all integrators must implement both methods, i.e. the equally-spaced and the x/y independently settable. It is mandatory that the x-array is sorted for ascending x-values.

Parameters:
x - A double-array representing the x-axis values.
y - A double-array representing the y-axis values.

setData

void setData(double[] y)
Sets an equally-spaced y-data set. Integration here assumes a step-size in x equal to one. Note that not necessarily all integrators must implement both methods, i.e. the equally-spaced and the x/y independently settable.

Parameters:
y - A double-array representing the y-axis values.

add

void add(double x,
         double y)
Adds a new point to the data set, stating both, the x and y value. The newly added x-value must be higher than any previously added or set x-value. Relies on a previously called initData(double, double). Note that not necessarily all integrators must implement both methods, i.e. the equally-spaced and the x/y independently settable.

Parameters:
x - A newly added x-value.
y - A newly added y-value.

add

void add(double y)
Adds a new point to the data set, stating only a y value for an equally-spaced data set. Relies on a previously called initData(double, double). Note that not necessarily all integrators must implement both methods, i.e. the equally-spaced and the x/y independently settable.

Parameters:
y - A newly added y-value.

initData

void initData(double xfirst,
              double yfirst)
Erases all previously added data points, starting a new data set. This also sets the lower-boundery on unspecific integrations with getIntegral().


getIntegral

double getIntegral()
Calculates the numerical integral over the entire set.


getIntegral

double getIntegral(double upper)
Calculates the numerical integral from the start of the set up to the desired upper-boundary.