nr
Class Function

java.lang.Object
  extended by nr.Function

public abstract class Function
extends java.lang.Object

A functionoid designed to implement a scalar function of a scalar

Author:
Daniel Wachsstock

Constructor Summary
Function()
           
 
Method Summary
 double derivative(double x)
          Calculates the derivative for this function.
 double derivativeCost()
          The computational cost of evaluating the derivative.
abstract  double eval(double x)
          a scalar function of a scalar.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Function

public Function()
Method Detail

eval

public abstract double eval(double x)
a scalar function of a scalar.

Parameters:
x - the independent variable
Returns:
the value

derivativeCost

public double derivativeCost()
The computational cost of evaluating the derivative. Some algorithms make decisions on how hard a calculation is, so this function should return the ratio of computer time in calling derivative(double) to eval(double). For the most part this can be ignored.

For the default derivative, derivativeCost = 2 (derivative calls eval twice).

Returns:
the relative cost of evaluating the derivative.

derivative

public double derivative(double x)
Calculates the derivative for this function. In the default implementation, it is calculated by symmetric finite differencing, as in Numerical Recipes eq. 5.7.7. This involves 2 calls to eval.

Parameters:
x - the independent variable
Returns:
df/dx evaluated at x