Celeritas
0.5.0-86+4a8eea4
|
Functor class to evaluate a polynomial. More...
#include <PolyEvaluator.hh>
Public Types | |
Type aliases | |
using | result_type = T |
using | argument_type = T |
using | ArrayT = Array< T, N+1 > |
Public Member Functions | |
template<class... Ts> | |
CELER_CONSTEXPR_FUNCTION | PolyEvaluator (Ts... coeffs) |
Construct with the polynomial to evaluate. | |
CELER_CONSTEXPR_FUNCTION | PolyEvaluator (ArrayT const &coeffs) |
Construct from an array of data. | |
CELER_CONSTEXPR_FUNCTION T | operator() (T arg) const |
Evaluate the polynomial at the given value. | |
Functor class to evaluate a polynomial.
This is an efficient and foolproof way of storing and evaluating a polynomial expansion:
\[ f(x) = a_0 + x * (a_1 + x * (a_2 + ...)) \]
It replaces opaque expressions such as:
with
or, to use an explicit type without having to cast each coefficient: