root/applications/pmsm/simulator_zdenek/ekf_example/fast_exp.h @ 1440

Revision 1440, 0.5 kB (checked in by smidl, 12 years ago)

rychly exp + vice clenu randn

Line 
1/* fast approximation of the exp function according to:
2 * NN Schraudolph, A fast, compact approximation of the exponential function, Neural Computation, 1999
3 */
4
5#include <math.h>
6static union
7{
8double d;
9struct
10{
11/*#ifdef LITTLE_ENDIAN -- PC & TMS2812 !!!*/
12int j, i;
13/*#else
14int i, j;
15#endif */
16} n;
17} _eco;
18#define EXP_A (1048576 /M_LN2)
19/* #define EXP_C 60801
20 */
21#define EXP_C 45799
22 
23/* use 1512775 for integer version */
24/* see text for choice of c values */
25#define EXP(y) (_eco.n.i = EXP_A*(y) + (1072693248 - EXP_C), _eco.d)
Note: See TracBrowser for help on using the browser.