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

NC::Fitter::FuncCache Class Reference

#include <NCFitter.h>

Inheritance diagram for NC::Fitter::FuncCache:

NC::Fitter::ICallableND List of all members.

Public Member Functions

 FuncCache (ICallableND *g)
virtual double EvalAtEx (const CoordNDim &r, CoordNDim *ret) const
 Find the value of the function and return additional information.

Protected Attributes

ICallableNDfFunc
std::map< CoordNDim, double > fCache
std::map< CoordNDim, CoordNDimfCacheRetCoord
int fNhit
int fNmiss

Friends

ostream & operator<< (ostream &os, const FuncCache &c)

Constructor & Destructor Documentation

NC::Fitter::FuncCache::FuncCache ICallableND g  )  [inline]
 

Definition at line 97 of file NCFitter.h.

00097 : fFunc(g), fNhit(0), fNmiss(0){}


Member Function Documentation

double NC::Fitter::FuncCache::EvalAtEx const CoordNDim r,
CoordNDim ret
const [virtual]
 

Find the value of the function and return additional information.

Parameters:
r Coordinate at which to evaluate the function
[out] ret Return additional information. By convention, the true underlying coordinates evaluated.
Returns:
Value of the function at the point r
Implementations must be prepared for ret to be null

Todo:
Rename to just EvalAt

Implements NC::Fitter::ICallableND.

Definition at line 138 of file NCFitter.cxx.

References NC::Fitter::CoordNDim, NC::Fitter::ICallableND::EvalAtEx(), fCache, fCacheRetCoord, and fFunc.

00139   {
00140     const std::map<CoordNDim, double>::const_iterator it = fCache.find(r);
00141     if(it != fCache.end()){
00142       ++fNhit;
00143       if(retCoord) *retCoord = fCacheRetCoord[r];
00144       return it->second;
00145     }
00146 
00147     ++fNmiss;
00148 
00149     //  const unsigned int maxCacheSize = int(1e7); // on the order of 10meg
00150     //  if(cache.size() > maxCacheSize) fCache.clear();
00151 
00152     CoordNDim myRetCoord;
00153     const double ret = fFunc->EvalAtEx(r, &myRetCoord);
00154 
00155     fCache[r] = ret;
00156     fCacheRetCoord[r] = myRetCoord;
00157 
00158     if(retCoord) *retCoord = myRetCoord;
00159     return ret;
00160   }


Friends And Related Function Documentation

ostream& operator<< ostream &  os,
const FuncCache c
[friend]
 

Definition at line 162 of file NCFitter.cxx.

00163   {
00164     os << "FuncCache for callable at " << c.fFunc
00165        << " with " << c.fNhit+c.fNmiss << " calls "
00166        << "of which " << c.fNhit << " hit and "
00167        << c.fNmiss << " missed." << endl;
00168     return os;
00169   }


Member Data Documentation

std::map<CoordNDim, double> NC::Fitter::FuncCache::fCache [mutable, protected]
 

Definition at line 101 of file NCFitter.h.

Referenced by EvalAtEx().

std::map<CoordNDim, CoordNDim> NC::Fitter::FuncCache::fCacheRetCoord [mutable, protected]
 

Definition at line 102 of file NCFitter.h.

Referenced by EvalAtEx().

ICallableND* NC::Fitter::FuncCache::fFunc [protected]
 

Definition at line 100 of file NCFitter.h.

Referenced by EvalAtEx(), and NC::Fitter::operator<<().

int NC::Fitter::FuncCache::fNhit [mutable, protected]
 

Definition at line 103 of file NCFitter.h.

Referenced by NC::Fitter::operator<<().

int NC::Fitter::FuncCache::fNmiss [mutable, protected]
 

Definition at line 103 of file NCFitter.h.

Referenced by NC::Fitter::operator<<().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:39 2010 for loon by  doxygen 1.3.9.1