Created
December 13, 2016 22:14
-
-
Save jhjin/4f7dbf063098133ef849f56e44c231a0 to your computer and use it in GitHub Desktop.
A Fast, Compact Approximation of the Exponential Function (double precision)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Fast, Compact Approximation of the Exponential Function | |
// http://www.schraudolph.org/pubs/Schraudolph99.pdf | |
inline double fast_exp(double y) { | |
double d; | |
*(reinterpret_cast<int*>(&d) + 0) = 0; | |
*(reinterpret_cast<int*>(&d) + 1) = static_cast<int>(1512775 * y + 1072632447); | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment