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

NC::Fitter::FuncCacheInt Class Reference

#include <NCFitter.h>

Inheritance diagram for NC::Fitter::FuncCacheInt:

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

Public Member Functions

 FuncCacheInt (const ICallableInt *g)
virtual double EvalAtEx (const CoordInt &r, CoordInt *) const

Protected Attributes

const ICallableIntfFunc
std::map< CoordInt, double > fCache
std::map< CoordInt, CoordIntfRetCache
int fNhit
int fNmiss

Friends

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

Constructor & Destructor Documentation

NC::Fitter::FuncCacheInt::FuncCacheInt const ICallableInt g  )  [inline]
 

Definition at line 114 of file NCFitter.h.

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


Member Function Documentation

double NC::Fitter::FuncCacheInt::EvalAtEx const CoordInt r,
CoordInt
const [virtual]
 

Reimplemented from NC::Fitter::ICallableInt.

Definition at line 172 of file NCFitter.cxx.

References NC::Fitter::CoordInt, NC::Fitter::ICallableInt::EvalAtEx(), fCache, fFunc, and fRetCache.

Referenced by NC::Fitter::FindContourInt().

00173   {
00174     const std::map<CoordInt, double>::const_iterator it = fCache.find(r);
00175 
00176     if(it != fCache.end()){
00177       ++fNhit;
00178       if(ret) *ret = fRetCache[r];
00179       return it->second;
00180     }
00181 
00182     ++fNmiss;
00183 
00184     //  const unsigned int maxCacheSize = int(1e7); // on the order of 10meg
00185     //  if(cache.size() > maxCacheSize) cache.clear();
00186 
00187     CoordInt myret;
00188     const double val = fFunc->EvalAtEx(r, &myret);
00189     if(ret) *ret = myret;
00190 
00191     fCache[r] = val;
00192     fRetCache[r] = myret;
00193 
00194     return val;
00195   }


Friends And Related Function Documentation

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

Definition at line 197 of file NCFitter.cxx.

00198   {
00199     os << "FuncCacheInt for callable at " << c.fFunc
00200        << " with " << c.fNhit+c.fNmiss << " calls "
00201        << "of which " << c.fNhit << " hit and "
00202        << c.fNmiss << " missed." << endl;
00203     return os;
00204   }


Member Data Documentation

std::map<CoordInt, double> NC::Fitter::FuncCacheInt::fCache [mutable, protected]
 

Definition at line 119 of file NCFitter.h.

Referenced by EvalAtEx().

const ICallableInt* NC::Fitter::FuncCacheInt::fFunc [protected]
 

Definition at line 118 of file NCFitter.h.

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

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

Definition at line 121 of file NCFitter.h.

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

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

Definition at line 121 of file NCFitter.h.

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

std::map<CoordInt, CoordInt> NC::Fitter::FuncCacheInt::fRetCache [mutable, protected]
 

Definition at line 120 of file NCFitter.h.

Referenced by EvalAtEx().


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