SctData::CachedFunction1D Class Reference

Caches the values of a 1-d function into a look-up table so that it can later be evaluated very quickly. More...

#include <CachedFunction1D.h>


Public Member Functions

 CachedFunction1D (double min, double max, double delta, double(*function)(double)) throw ()
 Constructor creates a look-up table for the function in the range [min,max) with step delta between x-values.
 ~CachedFunction1D () throw ()
 Deletes the table.
double eval (double x) const throw ()
 evaluate the function by picking a value from the look-up table.

Private Member Functions

 CachedFunction1D () throw ()
 not allowed to do this.
CachedFunction1Doperator= (const CachedFunction1D &) throw ()
 not allowed to do this.
void makeTable () throw ()
 called by the constructor to make the look-up table.

Private Attributes

double min
 min value of x for which the function is calculated.
double max
 min value of x for which the function is calculated.
double delta
 the step in x between points in the table.
double invdelta
 cached value of 1/delta.
int nvalue
 the number of values in the table.
double * values
 the table itself.
double(* function )(double)
 a pointer to the function itself.


Detailed Description

Caches the values of a 1-d function into a look-up table so that it can later be evaluated very quickly.

Author:
Alan Barr
Date:
3 April 2003

Definition at line 15 of file CachedFunction1D.h.


Constructor & Destructor Documentation

SctData::CachedFunction1D::CachedFunction1D double  min,
double  max,
double  delta,
double(*)(double)  function
throw ()
 

Constructor creates a look-up table for the function in the range [min,max) with step delta between x-values.

e.g. CachedFunction1D(0., 1., 0.001, &TMath::erf );

Parameters:
the minimum x-value
the maximum x-value
the x step size -> decrease for better precision.
the address of the function ``double f(double x)''

Definition at line 5 of file CachedFunction1D.cpp.

SctData::CachedFunction1D::~CachedFunction1D  )  throw ()
 

Deletes the table.

Definition at line 16 of file CachedFunction1D.cpp.

References values.

SctData::CachedFunction1D::CachedFunction1D  )  throw () [private]
 

not allowed to do this.


Member Function Documentation

double SctData::CachedFunction1D::eval double  x  )  const throw () [inline]
 

evaluate the function by picking a value from the look-up table.

Parameters:
the value of the function at which to evaluate
Returns:
the appropriate value from the look-up table. if x<min or x>max then f(min) or f(max) are returned respectively.

Definition at line 55 of file CachedFunction1D.h.

References Sct::min().

Referenced by SctData::erf(), SctData::erfc(), and SctData::tophat().

Here is the call graph for this function:

void SctData::CachedFunction1D::makeTable  )  throw () [private]
 

called by the constructor to make the look-up table.

Definition at line 20 of file CachedFunction1D.cpp.

References nvalue, and values.

CachedFunction1D& SctData::CachedFunction1D::operator= const CachedFunction1D  )  throw () [private]
 

not allowed to do this.


Field Documentation

double SctData::CachedFunction1D::delta [private]
 

the step in x between points in the table.

Definition at line 47 of file CachedFunction1D.h.

double(* SctData::CachedFunction1D::function)(double) [private]
 

a pointer to the function itself.

double SctData::CachedFunction1D::invdelta [private]
 

cached value of 1/delta.

Definition at line 48 of file CachedFunction1D.h.

double SctData::CachedFunction1D::max [private]
 

min value of x for which the function is calculated.

Definition at line 46 of file CachedFunction1D.h.

double SctData::CachedFunction1D::min [private]
 

min value of x for which the function is calculated.

Definition at line 45 of file CachedFunction1D.h.

int SctData::CachedFunction1D::nvalue [private]
 

the number of values in the table.

Definition at line 49 of file CachedFunction1D.h.

Referenced by makeTable().

double* SctData::CachedFunction1D::values [private]
 

the table itself.

Definition at line 50 of file CachedFunction1D.h.

Referenced by makeTable(), and ~CachedFunction1D().


The documentation for this class was generated from the following files:
Generated on Mon Feb 6 14:07:04 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6