Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
trento::FastExp< T > Class Template Reference

#include <JETSCAPE/blob/main/external_packages/trento/src/fast_exp.h>

+ Collaboration diagram for trento::FastExp< T >:

Public Member Functions

 FastExp (T xmin, T xmax, std::size_t nsteps)
 
T operator() (T x) const
 Evaluate the exponential at x (must be within range).
 

Private Attributes

const T xmin_
 Minimum and maximum.
 
const T xmax_
 
const T dx_
 Step size.
 
std::vector< Ttable_
 Tabulated exp() values.
 

Detailed Description

template<typename T = double>
class trento::FastExp< T >

Fast exponential approximation, to be used as a drop-in replacement for std::exp when it will be evaluated many times within a fixed range. Works by pre-tabulating exp() values and exploiting the leading-order Taylor expansion; for step size dx the error is \mathcal O(dx^2).

Example::

FastExp<double> fast_exp{0., 1., 11}; // tabulate at 0.0, 0.1, 0.2, ... fast_exp(0.50); // evaluate at table point -> exact result fast_exp(0.55); // midway between points -> worst-case error

Definition at line 29 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 29 of file fast_exp.h

Constructor & Destructor Documentation

template<typename T>
trento::FastExp< T >::FastExp ( T  xmin,
T  xmax,
std::size_t  nsteps 
)

Pre-tabulate exp() values from xmin to xmax in nsteps evenly-spaced intervals.

Definition at line 50 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 50 of file fast_exp.h

References trento::FastExp< T >::dx_, i, trento::FastExp< T >::table_, and trento::FastExp< T >::xmin_.

Member Function Documentation

template<typename T>
T trento::FastExp< T >::operator() ( T  x) const
inline

Evaluate the exponential at x (must be within range).

Definition at line 61 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 61 of file fast_exp.h

References index.

Member Data Documentation

template<typename T = double>
const T trento::FastExp< T >::dx_
private

Step size.

Definition at line 43 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 43 of file fast_exp.h

Referenced by trento::FastExp< T >::FastExp().

template<typename T = double>
std::vector<T> trento::FastExp< T >::table_
private

Tabulated exp() values.

Definition at line 46 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 46 of file fast_exp.h

Referenced by trento::FastExp< T >::FastExp().

template<typename T = double>
const T trento::FastExp< T >::xmax_
private

Definition at line 40 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 40 of file fast_exp.h

template<typename T = double>
const T trento::FastExp< T >::xmin_
private

Minimum and maximum.

Definition at line 40 of file fast_exp.h.

View newest version in sPHENIX GitHub at line 40 of file fast_exp.h

Referenced by trento::FastExp< T >::FastExp().


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