vec_math
Interface Differentiator

All Known Implementing Classes:
SimpleDifferentiator

public interface Differentiator

This interface defines calculus of a differentiator. 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 add values during the life-time of the differentiator using the add(double, double) method. Calling getDerivative() returns the first derivative at the cusp of the data points, i.e. at the highest x-value.
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 getDerivative()
          Calculates the first derivative at the highest x-value or at the most recently added y-value in equal-sized data sets.
 double getDerivative(double x)
          Calculates the first derivative at the stated x-value.
 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 differntiator 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. Differentiation here assumes a step-size in x equal to one. Note that not necessarily all differntiator 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. Note that not necessarily all differntiator 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. Note that not necessarily all differntiator must implement both, methods, i.e. the equally-spaced and the x/y independently settable.

Parameters:
y - A newly added y-value.

getDerivative

double getDerivative()
Calculates the first derivative at the highest x-value or at the most recently added y-value in equal-sized data sets. Note that not necessarily all differntiator must implement both derivative methods.


getDerivative

double getDerivative(double x)
Calculates the first derivative at the stated x-value. Note that not necessarily all differntiator must implement both derivative methods.