ATLAS Offline Software
Loading...
Searching...
No Matches
eflowLookupExp Class Reference

Lookup-table based exponential function to save CPU time, which is used by eflowCellIntegrator. More...

#include <eflowLookupExp.h>

Collaboration diagram for eflowLookupExp:

Public Member Functions

 eflowLookupExp (int nExpBins, int nExpSubBins)
 ~eflowLookupExp ()
double evaluate (double x) const

Static Public Member Functions

static const eflowLookupExpgetInstance (int nExpBins=50, int nExpSubBins=1000)

Private Attributes

int m_nExpBins
int m_nExpSubBins
std::vector< double > m_exp
std::vector< double > m_subExp

Detailed Description

Lookup-table based exponential function to save CPU time, which is used by eflowCellIntegrator.

Definition at line 22 of file eflowLookupExp.h.

Constructor & Destructor Documentation

◆ eflowLookupExp()

eflowLookupExp::eflowLookupExp ( int nExpBins,
int nExpSubBins )
inline

Definition at line 27 of file eflowLookupExp.h.

27 :
28 m_nExpBins(nExpBins), m_nExpSubBins(nExpSubBins), m_exp(nExpBins+1), m_subExp(nExpSubBins+1) {
29 /* Lookup table for the integer part of a number */
30 for (int i = 0; i <= nExpBins; ++i) {
31 m_exp[i] = exp(-i);
32 }
33 /* Lookup table for the fractional part of a number */
34 const double substep = 1./nExpSubBins;
35 for (int iSub = 0; iSub <= nExpSubBins; ++iSub){
36 m_subExp[iSub] = exp(-substep* iSub);
37 }
38 }
std::vector< double > m_subExp
std::vector< double > m_exp

◆ ~eflowLookupExp()

eflowLookupExp::~eflowLookupExp ( )
inline

Definition at line 40 of file eflowLookupExp.h.

40{ }

Member Function Documentation

◆ evaluate()

double eflowLookupExp::evaluate ( double x) const
inline

Definition at line 42 of file eflowLookupExp.h.

42 {
43 int iExpBin = (int) x;
44 int iSubBin(((x-iExpBin)*m_nExpSubBins));
45
46 if (iExpBin > m_nExpBins){
47 return exp(-x);
48 }
49 return m_exp[iExpBin]*m_subExp[iSubBin];
50 }
#define x

◆ getInstance()

const eflowLookupExp * eflowLookupExp::getInstance ( int nExpBins = 50,
int nExpSubBins = 1000 )
static

Definition at line 17 of file eflowLookupExp.cxx.

19{
21 if (!cached) {
22 cached.set (std::make_unique<eflowLookupExp>(nExpBins, nExpSubBins));
23 }
24
25 if ( (cached->m_nExpBins != nExpBins) || (cached->m_nExpSubBins != nExpSubBins) )
26 {
27 throw std::runtime_error("eflowLookupExp: Instance with different bin numbers than existing requested!");
28 }
29 return cached.get();
30}
#define ATLAS_THREAD_SAFE
CachedUniquePtrT< const T > CachedUniquePtr
cached(func)
Decorator to cache function return value.
Definition cached.py:6

Member Data Documentation

◆ m_exp

std::vector<double> eflowLookupExp::m_exp
private

Definition at line 55 of file eflowLookupExp.h.

◆ m_nExpBins

int eflowLookupExp::m_nExpBins
private

Definition at line 53 of file eflowLookupExp.h.

◆ m_nExpSubBins

int eflowLookupExp::m_nExpSubBins
private

Definition at line 54 of file eflowLookupExp.h.

◆ m_subExp

std::vector<double> eflowLookupExp::m_subExp
private

Definition at line 56 of file eflowLookupExp.h.


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