FInterpolate Class Reference

#include <finterpolate.h>

Inheritance diagram for FInterpolate:
Inheritance graph
[legend]
Collaboration diagram for FInterpolate:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FInterpolate (Function1D &f, double a, double b, unsigned N)
virtual double operator() (double x, unsigned cmp) const
virtual bool isInDomain (double x, unsigned cmp) const
virtual ~FInterpolate ()

Private Attributes

Function1D_f
double _a
double _b
unsigned _N
double _dx
VecDouble _fVals

Detailed Description

Definition at line 17 of file finterpolate.h.


Constructor & Destructor Documentation

FInterpolate::FInterpolate ( Function1D f,
double  a,
double  b,
unsigned  N 
)

Definition at line 3 of file finterpolate.cpp.

00003                                                                        :_f(f)
00004 {
00005         _a=a;
00006         _b=b;
00007         assert(_a < _b);
00008         _N=N;
00009         _dx=(_b-_a)/_N;
00010 
00011         _fVals.reinit(_N+1);
00012         for (int i=0; i<=_N; i++) _fVals(i)=_f(_a+i*_dx);
00013 }

FInterpolate::~FInterpolate (  )  [virtual]

Definition at line 29 of file finterpolate.cpp.

00029 {}


Member Function Documentation

bool FInterpolate::isInDomain ( double  x,
unsigned  cmp = 0 
) const [virtual]

Reimplemented from Function1D.

Definition at line 23 of file finterpolate.cpp.

00024 {
00025         if (_a <= x && x <= _b) return 1;
00026         return 0;
00027 }

double FInterpolate::operator() ( double  x,
unsigned  cmp = 0 
) const [virtual]

Implements Function1D.

Definition at line 15 of file finterpolate.cpp.

00016 {
00017         assert(isInDomain(x,cmp));
00018         unsigned index = floor((x-_a)/_dx);
00019         if (index == _N) return _fVals(_N);
00020         return ((_fVals(index+1)-_fVals(index))/_dx )*(x-(_a+(index)*_dx)) + _fVals(index);
00021 }


Member Data Documentation

double FInterpolate::_a [private]

Definition at line 21 of file finterpolate.h.

double FInterpolate::_b [private]

Definition at line 21 of file finterpolate.h.

double FInterpolate::_dx [private]

Definition at line 23 of file finterpolate.h.

Definition at line 20 of file finterpolate.h.

Definition at line 24 of file finterpolate.h.

unsigned FInterpolate::_N [private]

Definition at line 22 of file finterpolate.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:06 2012 for CO2INJECTION by  doxygen 1.6.3