Download envs/kitoverlay/skimage/_shared/fast_exp.h from AVSim/simulation-package: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/datasets/AVSim/simulation-package/resolve/main/envs/kitoverlay/skimage/_shared/fast_exp.h
- Command line
-
hf download hf://datasets/AVSim/simulation-package/envs/kitoverlay/skimage/_shared/fast_exp.h
-
curl -L -o fast_exp.h https://huggingface.co/datasets/AVSim/simulation-package/resolve/main/envs/kitoverlay/skimage/_shared/fast_exp.h
1.25 kB
| /* A fast approximation of the exponential function. | |
| * Reference [1]: https://schraudolph.org/pubs/Schraudolph99.pdf | |
| * Reference [2]: https://doi.org/10.1162/089976600300015033 | |
| * Additional improvements by Leonid Bloch. */ | |
| /* use just EXP_A = 1512775 for integer version, to avoid FP calculations */ | |
| /* For min. RMS error */ | |
| /* For min. max. relative error */ | |
| /* #define EXP_BC 1072647449 */ /* 1023*2^20 - 45799 */ | |
| /* For min. mean relative error */ | |
| /* #define EXP_BC 1072625005 */ /* 1023*2^20 - 68243 */ | |
| __inline double _fast_exp (double y) | |
| { | |
| union | |
| { | |
| double d; | |
| struct { int32_t i, j; } n; | |
| char t[8]; | |
| } _eco; | |
| _eco.n.i = 1; | |
| switch(_eco.t[0]) { | |
| case 1: | |
| /* Little endian */ | |
| _eco.n.j = (int32_t)(EXP_A*(y)) + EXP_BC; | |
| _eco.n.i = 0; | |
| break; | |
| case 0: | |
| /* Big endian */ | |
| _eco.n.i = (int32_t)(EXP_A*(y)) + EXP_BC; | |
| _eco.n.j = 0; | |
| break; | |
| } | |
| return _eco.d; | |
| } | |
| __inline float _fast_expf (float y) | |
| { | |
| return (float)_fast_exp((double)y); | |
| } | |