43# define SAMPPROD int64_t
44#define SAMP_MAX 2147483647
47# define SAMPPROD int32_t
51#define SAMP_MIN -SAMP_MAX
53#if defined(CHECK_OVERFLOW)
54# define CHECK_OVERFLOW_OP(a,op,b) \
55 if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
56 fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
60# define smul(a,b) ( (SAMPPROD)(a)*(b) )
61# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
63# define S_MUL(a,b) sround( smul(a,b) )
65# define C_MUL(m,a,b) \
66 do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
67 (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
69# define DIVSCALAR(x,k) \
70 (x) = sround( smul( x, SAMP_MAX/k ) )
72# define C_FIXDIV(c,div) \
73 do { DIVSCALAR( (c).r , div); \
74 DIVSCALAR( (c).i , div); }while (0)
76# define C_MULBYSCALAR( c, s ) \
77 do{ (c).r = sround( smul( (c).r , s ) ) ;\
78 (c).i = sround( smul( (c).i , s ) ) ; }while(0)
82# define S_MUL(a,b) ( (a)*(b) )
84 do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
85 (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
86# define C_FIXDIV(c,div)
87# define C_MULBYSCALAR( c, s ) \
89 (c).i *= (s); }while(0)
92#ifndef CHECK_OVERFLOW_OP
93# define CHECK_OVERFLOW_OP(a,op,b)
96#define C_ADD( res, a,b)\
98 CHECK_OVERFLOW_OP((a).r,+,(b).r)\
99 CHECK_OVERFLOW_OP((a).i,+,(b).i)\
100 (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
102#define C_SUB( res, a,b)\
104 CHECK_OVERFLOW_OP((a).r,-,(b).r)\
105 CHECK_OVERFLOW_OP((a).i,-,(b).i)\
106 (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
108#define C_ADDTO( res , a)\
110 CHECK_OVERFLOW_OP((res).r,+,(a).r)\
111 CHECK_OVERFLOW_OP((res).i,+,(a).i)\
112 (res).r += (a).r; (res).i += (a).i;\
115#define C_SUBFROM( res , a)\
117 CHECK_OVERFLOW_OP((res).r,-,(a).r)\
118 CHECK_OVERFLOW_OP((res).i,-,(a).i)\
119 (res).r -= (a).r; (res).i -= (a).i; \
124# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase))
125# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase))
126# define HALF_OF(x) ((x)>>1)
127#elif defined(USE_SIMD)
128# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
129# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
130# define HALF_OF(x) ((x)*_mm_set1_ps(.5))
132# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
133# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
134# define HALF_OF(x) ((x)*.5)
137#define kf_cexp(x,phase) \
139 (x)->r = KISS_FFT_COS(phase);\
140 (x)->i = KISS_FFT_SIN(phase);\
146 fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
149#ifdef KISS_FFT_USE_ALLOCA
155#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes)
156#define KISS_FFT_TMP_FREE(ptr)
158#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
159#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
int factors[2 *MAXFACTORS]