CachedFunction1D.cpp

00001 #include "CachedFunction1D.h"
00002 
00003 namespace SctData{
00004     
00005     CachedFunction1D::CachedFunction1D(double min, double max, double delta, double (*function) (double) ) throw() :
00006     min(min), max(max), delta(delta), function(function) {
00007     
00008     //Make sure min and max are definately included in range
00009     nvalue= (int)(ceil(max/delta) - floor(min/delta));
00010     
00011     values=new double[nvalue];
00012     makeTable();
00013     invdelta= 1./ delta;
00014     }
00015     
00016     CachedFunction1D::~CachedFunction1D() throw() {
00017     delete [] values;
00018     }
00019     
00020     void CachedFunction1D::makeTable() throw() {
00021     for ( int i=0; i<nvalue; ++i){ 
00022         double xx = min + delta*i;
00023         values[i] = (*function)(xx) ;
00024     };
00025     }
00026 
00027 }

Generated on Mon Feb 6 14:01:17 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6