Analysis Software
Documentation for sPHENIX simulation software
|
#include <JETSCAPE/blob/main/external_packages/trento/src/fast_exp.h>
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< T > | table_ |
Tabulated exp() values. | |
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
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_.
|
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.
|
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().
|
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().
|
private |
Definition at line 40 of file fast_exp.h.
View newest version in sPHENIX GitHub at line 40 of file fast_exp.h
|
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().