Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mlib::TabulatedFunction Class Reference
[MLIB]

Tabulates values of a given function over an interval [a,b] using a specified resolution.

Approximations of the function at values in [a,b) are returned as interpolations of the tabulated values. at values outside that range the function itself is used to compute the value. More...

#include <tab_fn.H>

List of all members.

Public Member Functions

Constructors
 TabulatedFunction (double a, double b, real_fn_t f, int res)
 Constructor that tabulates the function f over the range [a,b) by taking res samples.
 TabulatedFunction (double a, double b, double vals[], int res)
 Constructor that creates a tabulated function over the range [a,b) from the values in vals.
Initialization Functions
void init (double a, double b, double vals[], int res)
 Creates a tabulated function over the range [a,b) from the values in vals.
void init (double a, double b, real_fn_t f, int res)
 Tabulates the function f over the range [a,b) by taking res samples.
Tabulated Function Evaulation
double map (double x) const
 Evaluates the tabulated function at x.

Protected Attributes

double _a
 a (the start of the interval over which the function is tabulated)
double _b
 b (the end of the interval over which the function is tabulated)
double _len
 b - a (the length of the interval over which the function is tabulated)
int _res
 resolution (# of subintervals)
double _rlen
 _res / _len (used in computation)
double * _tab
 table of values
real_fn_t _f
 the given function

Related Functions

(Note that these are not member functions.)

typedef double(* real_fn_t )(double)
 Function pointer type for the type of functions that can be tabulated by the TabulatedFunction class.


Detailed Description

Tabulates values of a given function over an interval [a,b] using a specified resolution.

Approximations of the function at values in [a,b) are returned as interpolations of the tabulated values. at values outside that range the function itself is used to compute the value.

Definition at line 30 of file tab_fn.H.


Constructor & Destructor Documentation

mlib::TabulatedFunction::TabulatedFunction double  a,
double  b,
real_fn_t  f,
int  res
[inline]
 

Constructor that tabulates the function f over the range [a,b) by taking res samples.

Definition at line 53 of file tab_fn.H.

References init().

mlib::TabulatedFunction::TabulatedFunction double  a,
double  b,
double  vals[],
int  res
[inline]
 

Constructor that creates a tabulated function over the range [a,b) from the values in vals.

vals should have at least res elements.

Definition at line 62 of file tab_fn.H.

References init().


Member Function Documentation

void mlib::TabulatedFunction::init double  a,
double  b,
real_fn_t  f,
int  res
[inline]
 

Tabulates the function f over the range [a,b) by taking res samples.

Parameters:
[in] a The start of the range over which to tabulate f.
[in] b The end of the range over which to tabulate f.
[in] f The function to tabulate.
[in] res The number of samples to take while tabulating f.
Bug:
This function checks the for allocation errors from the new operator incorrectly (new doesn't return a null pointer on failure, it throws a bad_alloc exception).

Definition at line 120 of file tab_fn.H.

References _a, _b, _f, _len, _res, _rlen, _tab, err_msg(), and err_ret().

void mlib::TabulatedFunction::init double  a,
double  b,
double  vals[],
int  res
[inline]
 

Creates a tabulated function over the range [a,b) from the values in vals.

Note:
vals should have at least res elements.
Parameters:
[in] a The start of the range of the tabulated function.
[in] b The end of the range of the tabulated function.
[in] vals The values to use as samples of the tabulated function.
[in] res The number of samples in vals.
Bug:
This function checks the for allocation errors from the new operator incorrectly (new doesn't return a null pointer on failure, it throws a bad_alloc exception).

Definition at line 85 of file tab_fn.H.

References _a, _b, _f, _len, _res, _rlen, _tab, err_msg(), and err_ret().

Referenced by TabulatedFunction().

double mlib::TabulatedFunction::map double  x  )  const [inline]
 

Evaluates the tabulated function at x.

Computes the interpolated values of the tabulated function at x.

If x is out of bounds, evaluate the function directly if we have it. If we don't have it, extend the tabulated function to be constant outside of its defined range.

Definition at line 156 of file tab_fn.H.

References _a, _b, _f, _res, _rlen, _tab, and int().


Friends And Related Function Documentation

typedef double(* real_fn_t)(double) [related]
 

Function pointer type for the type of functions that can be tabulated by the TabulatedFunction class.

Definition at line 18 of file tab_fn.H.


Member Data Documentation

double mlib::TabulatedFunction::_a [protected]
 

a (the start of the interval over which the function is tabulated)

Definition at line 36 of file tab_fn.H.

Referenced by init(), and map().

double mlib::TabulatedFunction::_b [protected]
 

b (the end of the interval over which the function is tabulated)

Definition at line 38 of file tab_fn.H.

Referenced by init(), and map().

real_fn_t mlib::TabulatedFunction::_f [protected]
 

the given function

Definition at line 44 of file tab_fn.H.

Referenced by init(), and map().

double mlib::TabulatedFunction::_len [protected]
 

b - a (the length of the interval over which the function is tabulated)

Definition at line 40 of file tab_fn.H.

Referenced by init().

int mlib::TabulatedFunction::_res [protected]
 

resolution (# of subintervals)

Definition at line 41 of file tab_fn.H.

Referenced by init(), and map().

double mlib::TabulatedFunction::_rlen [protected]
 

_res / _len (used in computation)

Definition at line 42 of file tab_fn.H.

Referenced by init(), and map().

double* mlib::TabulatedFunction::_tab [protected]
 

table of values

Definition at line 43 of file tab_fn.H.

Referenced by init(), and map().


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 11:48:25 2006 for jot by  doxygen 1.4.4