base_interp Class Template Reference

Base low-level interpolation class [abstract base]. More...

#include <interp.h>

Inheritance diagram for base_interp:

akima_interp cspline_interp linear_interp akima_peri_interp cspline_peri_interp

Detailed Description

template<class vec_t>
class base_interp< vec_t >

Base low-level interpolation class [abstract base].

The descendants of this class are intended to be fast interpolation routines for increasing functions, leaving the some error handling, user-friendliness, and other more complicated improvements for other classes.

For any pair of vectors x and y into which you would like to interpolate, you need to call allocate() and init() first, and then the interpolation functions, and then free(). If the next pair of vectors has the same size, then you need only to call init() before the next call to an interpolation function. If the vectors do not change, then you may call the interpolation functions in succession.

All of the descendants are based on the GSL interpolation routines and give identical results.

Idea for future:
These might work for decreasing functions by just replacing calls to search_vec::bsearch_inc() with search_vec::bsearch_dec(). If this is the case, then this should be rewritten accordingly. (I think I might have removed the acceleration)

Definition at line 67 of file interp.h.


Public Member Functions

virtual int allocate (size_t size)
 Allocate memory, assuming x and y have size size.
virtual int free ()
 Free allocated memory.
virtual int init (const vec_t &x, const vec_t &y, size_t size)
 Initialize interpolation routine.
virtual int interp (const vec_t &x, const vec_t &y, size_t size, double x0, double &y0)=0
 Give the value of the function $ y(x=x_0) $ .
virtual int deriv (const vec_t &x, const vec_t &y, size_t size, double x0, double &dydx)=0
 Give the value of the derivative $ y^{\prime}(x=x_0) $ .
virtual int deriv2 (const vec_t &x, const vec_t &y, size_t size, double x0, double &d2ydx2)=0
 Give the value of the second derivative $ y^{\prime \prime}(x=x_0) $ .
virtual int integ (const vec_t &x, const vec_t &y, size_t size, double a, double b, double &result)=0
 Give the value of the integral $ \int_a^{b}y(x)~dx $ .
virtual const char * type ()
 Return the type, "base_interp".

Data Fields

size_t min_size
 The minimum size of the vectors to interpolate between.

Protected Member Functions

double integ_eval (double ai, double bi, double ci, double di, double xi, double a, double b)
 An internal function to assist in computing the integral for both the cspline and Akima types.

Protected Attributes

search_vec< vec_t > sv
 The binary search object.

Private Member Functions

 base_interp (const base_interp< vec_t > &)
base_interp< vec_t > & operator= (const base_interp< vec_t > &)

Field Documentation

size_t min_size

The minimum size of the vectors to interpolate between.

This needs to be set in the constructor of the children for access by the class user

Definition at line 108 of file interp.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page