|
Revision 1440, 0.5 kB
(checked in by smidl, 14 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> |
|---|
| 6 | static union |
|---|
| 7 | { |
|---|
| 8 | double d; |
|---|
| 9 | struct |
|---|
| 10 | { |
|---|
| 11 | /*#ifdef LITTLE_ENDIAN -- PC & TMS2812 !!!*/ |
|---|
| 12 | int j, i; |
|---|
| 13 | /*#else |
|---|
| 14 | int 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) |
|---|