![]() |
deal.II version 9.8.0
|
Namespaces | |
| namespace | internal |
Enumerations | |
| enum class | PolynomialEvalScheme : int { estrin , horner } |
Functions | |
| template<int degree, typename Number, bool ensure_correct_treatment_of_zero = true, bool ensure_correct_treatment_of_infinity = true, PolynomialEvalScheme polynomial_evaluation_scheme = PolynomialEvalScheme::horner> | |
| Number | exp (Number x) |
|
strong |
Enumeration of available polynomial evaluation schemes for the correction polynomial in fast_exp_approximation().
| Enumerator | |
|---|---|
| estrin | |
| horner | |
Definition at line 414 of file fast_transcendental.h.
|
inline |
This function provides a fully vectorizable algorithm for approximating the exponential function. In contrast to the standard std::exp() implementation, this algorithm is designed for SIMD execution and therefore offers significant performance advantages in vectorized computations while maintaining high accuracy. The main algorithm is briefly summarized here. For more details see [Proell2024].
The algorithm is based on the IEEE-754 floating-point representation
![\[ (-1)^s 2^{p-b} (1+m),
\]](form_477.png)
where 




For the exponential function one can write
![\[ \exp(x)
= 2^{x \log_2(e)}
= 2^y
= 2^{y_i}2^{y_f},
\]](form_480.png)
where 


![\[ s = 0,\qquad 2^{y_i} = 2^{p-b},\qquad 2^{y_f} = 1 + m.
\]](form_484.png)
The integer exponent 



To avoid transcendental operations, a correction function
![\[ K(y_f) = 1 + y_f - 2^{y_f},
\]](form_489.png)
which is approximated using a polynomial of configurable degree, is introduced. With this approximation, the mantissa can be written as
![\[ m = y_f - K(y_f).
\]](form_490.png)
The accuracy of the exponential approximation depends primarily on the polynomial used for 
Once the mantissa and exponent have been computed, the final floating-point value is assembled through internal bit manipulation that constructs the correct IEEE-754 representation. For further algorithmic details, see the referenced literature.
This function optionally performs lower- and upper-bound checks on the input values. If enabled:
Two schemes are available for evaluating the correction polynomial: (Horner's method)[https://en.wikipedia.org/wiki/Horner%27s_method], which minimizes the operation count, and (Estrin's method)[https://en.wikipedia.org/wiki/Estrin%27s_scheme], which performs slightly more operations but makes better use of modern hardware parallelism. The preferable scheme can vary depending on the application and system architecture and should be assessed separately for each use case.
| degree | Degree of the polynomial used to approximate the correction function. |
| Number | The floating-point data type. Only double and float are supported. |
| width | The SIMD vector width. |
| ensure_correct_treatment_of_zero | Whether to perform an underflow check. |
| ensure_correct_treatment_of_infinity | Whether to perform an overflow check. |
| polynomial_evaluation_scheme | The polynomial evaluation scheme to be used for the evaluation of the correction function. |
| x | The vector of values at which the exponential function is approximated. |

Definition at line 514 of file fast_transcendental.h.