/* fast approximation of the exp function according to:
 * NN Schraudolph, A fast, compact approximation of the exponential function, Neural Computation, 1999 
 */

#include <math.h>
static union
{
double d;
struct
{
/*#ifdef LITTLE_ENDIAN -- PC & TMS2812 !!!*/
int j, i;
/*#else
int i, j;
#endif */
} n;
} _eco;
#define EXP_A (1048576 /M_LN2)
/* #define EXP_C 60801 
 */
#define EXP_C 45799
 
/* use 1512775 for integer version */
/* see text for choice of c values */
#define EXP(y) (_eco.n.i = EXP_A*(y) + (1072693248 - EXP_C), _eco.d)
