NFFT  3.3.1alpha
infft.h
1 /*
2  * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
22 #ifndef __INFFT_H__
23 #define __INFFT_H__
24 
25 #include "config.h"
26 
27 #include <math.h>
28 #include <float.h>
29 #ifdef HAVE_COMPLEX_H
30 #include <complex.h>
31 #endif
32 #include <stdio.h>
33 #include <string.h>
34 
35 #include <stdlib.h> /* size_t */
36 #include <stdarg.h> /* va_list */
37 #include <stddef.h> /* ptrdiff_t */
38 
39 #if HAVE_SYS_TYPES_H
40 #include <sys/types.h>
41 #endif
42 
43 #if HAVE_STDINT_H
44 #include <stdint.h> /* uintptr_t, maybe */
45 #endif
46 
47 #if HAVE_INTTYPES_H
48 #include <inttypes.h> /* uintptr_t, maybe */
49 #endif
50 
51 #include <fftw3.h>
52 
53 #include "ticks.h"
54 
66 /* Determine precision and name-mangling scheme. */
67 #define CONCAT(prefix, name) prefix ## name
68 #if defined(NFFT_SINGLE)
69 typedef float R;
70 typedef float _Complex C;
71 #define Y(name) CONCAT(nfftf_,name)
72 #define FFTW(name) CONCAT(fftwf_,name)
73 #define NFFT(name) CONCAT(nfftf_,name)
74 #define NFCT(name) CONCAT(nfctf_,name)
75 #define NFST(name) CONCAT(nfstf_,name)
76 #define NFSFT(name) CONCAT(nfsftf_,name)
77 #define SOLVER(name) CONCAT(solverf_,name)
78 #elif defined(NFFT_LDOUBLE)
79 typedef long double R;
80 typedef long double _Complex C;
81 #define Y(name) CONCAT(nfftl_,name)
82 #define FFTW(name) CONCAT(fftwl_,name)
83 #define NFFT(name) CONCAT(nfftl_,name)
84 #define NFCT(name) CONCAT(nfctl_,name)
85 #define NFST(name) CONCAT(nfstl_,name)
86 #define NFSFT(name) CONCAT(nfsftl_,name)
87 #define SOLVER(name) CONCAT(solverl_,name)
88 #else
89 typedef double R;
90 typedef double _Complex C;
91 #define Y(name) CONCAT(nfft_,name)
92 #define FFTW(name) CONCAT(fftw_,name)
93 #define NFFT(name) CONCAT(nfft_,name)
94 #define NFCT(name) CONCAT(nfct_,name)
95 #define NFST(name) CONCAT(nfst_,name)
96 #define NFSFT(name) CONCAT(nfsft_,name)
97 #define SOLVER(name) CONCAT(solver_,name)
98 #endif
99 #define X(name) Y(name)
100 
101 #define STRINGIZEx(x) #x
102 #define STRINGIZE(x) STRINGIZEx(x)
103 
104 #ifdef NFFT_LDOUBLE
105 # define K(x) ((R) x##L)
106 #else
107 # define K(x) ((R) x)
108 #endif
109 #define DK(name, value) const R name = K(value)
110 
111 #if defined __CYGWIN32__ && !defined __CYGWIN__
112  /* For backwards compatibility with Cygwin b19 and
113  earlier, we define __CYGWIN__ here, so that
114  we can rely on checking just for that macro. */
115 # define __CYGWIN__ __CYGWIN32__
116 #endif
117 
118 #if defined _WIN32 && !defined __CYGWIN__
119  /* Use Windows separators on all _WIN32 defining
120  environments, except Cygwin. */
121 # define SEP "\\"
122 #endif
123 #ifndef SEP
124  /* Assume that not having this is an indicator that all
125  are missing. */
126 # define SEP "/"
127 #endif /* !DIR_SEPARATOR_CHAR */
128 
129 /* Integral type large enough to contain a stride (what ``int'' should have been
130  * in the first place) */
131 typedef ptrdiff_t INT;
132 
133 #define KPI K(3.1415926535897932384626433832795028841971693993751)
134 #define K2PI K(6.2831853071795864769252867665590057683943387987502)
135 #define K4PI K(12.5663706143591729538505735331180115367886775975004)
136 #define KE K(2.7182818284590452353602874713526624977572470937000)
137 
138 #define IF(x,a,b) ((x)?(a):(b))
139 #define MIN(a,b) (((a)<(b))?(a):(b))
140 #define MAX(a,b) (((a)>(b))?(a):(b))
141 #define ABS(x) (((x)>K(0.0))?(x):(-(x)))
142 #define SIGN(a) (((a)>=0)?1:-1)
143 #define SIGN(a) (((a)>=0)?1:-1)
144 #define SIGNF(a) IF((a)<K(0.0),K(-1.0),K(1.0))
145 
146 /* Size of array. */
147 #define SIZE(x) sizeof(x)/sizeof(x[0])
148 
150 #define CSWAP(x,y) {C* NFFT_SWAP_temp__; \
151  NFFT_SWAP_temp__=(x); (x)=(y); (y)=NFFT_SWAP_temp__;}
152 
154 #define RSWAP(x,y) {R* NFFT_SWAP_temp__; NFFT_SWAP_temp__=(x); \
155  (x)=(y); (y)=NFFT_SWAP_temp__;}
156 
157 /* macros for window functions */
158 
159 #if defined(DIRAC_DELTA)
160  #define PHI_HUT(n,k,d) K(1.0)
161  #define PHI(n,x,d) IF(FABS((x)) < K(10E-8),K(1.0),K(0.0))
162  #define WINDOW_HELP_INIT(d)
163  #define WINDOW_HELP_FINALIZE
164  #define WINDOW_HELP_ESTIMATE_m 0
165 #elif defined(GAUSSIAN)
166  #define PHI_HUT(n,k,d) ((R)EXP(-(POW(KPI*(k)/n,K(2.0))*ths->b[d])))
167  #define PHI(n,x,d) ((R)EXP(-POW((x)*((R)n),K(2.0)) / \
168  ths->b[d])/SQRT(KPI*ths->b[d]))
169  #define WINDOW_HELP_INIT \
170  { \
171  int WINDOW_idx; \
172  ths->b = (R*) Y(malloc)(ths->d*sizeof(R)); \
173  for (WINDOW_idx = 0; WINDOW_idx < ths->d; WINDOW_idx++) \
174  ths->b[WINDOW_idx]=(K(2.0)*ths->sigma[WINDOW_idx]) / \
175  (K(2.0)*ths->sigma[WINDOW_idx] - K(1.0)) * (((R)ths->m) / KPI); \
176  }
177  #define WINDOW_HELP_FINALIZE {Y(free)(ths->b);}
178 #if defined(NFFT_LDOUBLE)
179  #define WINDOW_HELP_ESTIMATE_m 17
180 #elif defined(NFFT_SINGLE)
181  #define WINDOW_HELP_ESTIMATE_m 5
182 #else
183  #define WINDOW_HELP_ESTIMATE_m 13
184 #endif
185 #elif defined(B_SPLINE)
186  #define PHI_HUT(n,k,d) ((R)(((k) == 0) ? K(1.0) / n : \
187  POW(SIN((k) * KPI / n) / ((k) * KPI / n), \
188  K(2.0) * ths->m)/n))
189  #define PHI(n,x,d) (Y(bsplines)(2*ths->m,((x)*n) + \
190  (R)ths->m) / n)
191  #define WINDOW_HELP_INIT
192  #define WINDOW_HELP_FINALIZE
193 #if defined(NFFT_LDOUBLE)
194  #define WINDOW_HELP_ESTIMATE_m 11
195 #elif defined(NFFT_SINGLE)
196  #define WINDOW_HELP_ESTIMATE_m 11
197 #else
198  #define WINDOW_HELP_ESTIMATE_m 11
199 #endif
200 #elif defined(SINC_POWER)
201  #define PHI_HUT(n,k,d) (Y(bsplines)(2 * ths->m, (K(2.0) * ths->m*(k)) / \
202  ((K(2.0) * ths->sigma[(d)] - 1) * n / \
203  ths->sigma[(d)]) + (R)ths->m))
204  #define PHI(n,x,d) ((R)(n / ths->sigma[(d)] * \
205  (K(2.0) * ths->sigma[(d)] - K(1.0))/ (K(2.0)*ths->m) * \
206  POW(Y(sinc)(KPI * n / ths->sigma[(d)] * (x) * \
207  (K(2.0) * ths->sigma[(d)] - K(1.0)) / (K(2.0)*ths->m)) , 2*ths->m) / \
208  n))
209  #define WINDOW_HELP_INIT
210  #define WINDOW_HELP_FINALIZE
211 #if defined(NFFT_LDOUBLE)
212  #define WINDOW_HELP_ESTIMATE_m 13
213 #elif defined(NFFT_SINGLE)
214  #define WINDOW_HELP_ESTIMATE_m 11
215 #else
216  #define WINDOW_HELP_ESTIMATE_m 11
217 #endif
218 #else /* Kaiser-Bessel is the default. */
219  #define PHI_HUT(n,k,d) (Y(bessel_i0)((R)(ths->m) * SQRT(ths->b[d] * ths->b[d] - (K(2.0) * KPI * (R)(k) / (R)(n)) * (K(2.0) * KPI * (R)(k) / (R)(n)))))
220  #define PHI(n,x,d) ( (((R)(ths->m) * (R)(ths->m) - (x) * (R)(n) * (x) * (R)(n)) > K(0.0)) \
221  ? SINH(ths->b[d] * SQRT((R)(ths->m) * (R)(ths->m) - (x) * (R)(n) * (x) * (R)(n))) \
222  / (KPI * SQRT((R)(ths->m) * (R)(ths->m) - (x) * (R)(n) * (x) * (R)(n))) \
223  : ((((R)(ths->m) * (R)(ths->m) - (x) * (R)(n) * (x) * (R)(n)) < K(0.0)) \
224  ? SIN(ths->b[d] * SQRT((x) * (R)(n) * (x) * (R)(n) - (R)(ths->m) * (R)(ths->m))) \
225  / (KPI * SQRT((x) * (R)(n) * (x) * (R)(n) - (R)(ths->m) * (R)(ths->m))) \
226  : ths->b[d] / KPI))
227  #define WINDOW_HELP_INIT \
228  { \
229  int WINDOW_idx; \
230  ths->b = (R*) Y(malloc)((size_t)(ths->d) * sizeof(R)); \
231  for (WINDOW_idx = 0; WINDOW_idx < ths->d; WINDOW_idx++) \
232  ths->b[WINDOW_idx] = (KPI * (K(2.0) - K(1.0) / ths->sigma[WINDOW_idx])); \
233  }
234  #define WINDOW_HELP_FINALIZE {Y(free)(ths->b);}
235  #if defined(NFFT_LDOUBLE)
236  #define WINDOW_HELP_ESTIMATE_m 9
237  #elif defined(NFFT_SINGLE)
238  #define WINDOW_HELP_ESTIMATE_m 4
239  #else
240  #define WINDOW_HELP_ESTIMATE_m 8
241  #endif
242 #endif
243 
244 /* window.c */
245 INT Y(m2K)(const INT m);
246 
247 #if defined(NFFT_LDOUBLE)
248 #if HAVE_DECL_COPYSIGNL == 0
249 extern long double copysignl(long double, long double);
250 #endif
251 #if HAVE_DECL_NEXTAFTERL == 0
252 extern long double nextafterl(long double, long double);
253 #endif
254 #if HAVE_DECL_NANL == 0
255 extern long double nanl(const char *tag);
256 #endif
257 #if HAVE_DECL_CEILL == 0
258 extern long double ceill(long double);
259 #endif
260 #if HAVE_DECL_FLOORL == 0
261 extern long double floorl(long double);
262 #endif
263 #if HAVE_DECL_NEARBYINTL == 0
264 extern long double nearbyintl(long double);
265 #endif
266 #if HAVE_DECL_RINTL == 0
267 extern long double rintl(long double);
268 #endif
269 #if HAVE_DECL_ROUNDL == 0
270 extern long double roundl(long double);
271 #endif
272 #if HAVE_DECL_LRINTL == 0
273 extern long int lrintl(long double);
274 #endif
275 #if HAVE_DECL_LROUNDL == 0
276 extern long int lroundl(long double);
277 #endif
278 #if HAVE_DECL_LLRINTL == 0
279 extern long long int llrintl(long double);
280 #endif
281 #if HAVE_DECL_LLROUNDL == 0
282 extern long long int llroundl(long double);
283 #endif
284 #if HAVE_DECL_TRUNCL == 0
285 extern long double truncl(long double);
286 #endif
287 #if HAVE_DECL_FMODL == 0
288 extern long double fmodl(long double, long double);
289 #endif
290 #if HAVE_DECL_REMAINDERL == 0
291 extern long double remainderl(long double, long double);
292 #endif
293 #if HAVE_DECL_REMQUOL == 0
294 extern long double remquol(long double x, long double y, int *);
295 #endif
296 #if HAVE_DECL_FDIML == 0
297 extern long double fdiml(long double, long double);
298 #endif
299 #if HAVE_DECL_FMAXL == 0
300 extern long double fmaxl(long double, long double);
301 #endif
302 #if HAVE_DECL_FMINL == 0
303 extern long double fminl(long double, long double);
304 #endif
305 #if HAVE_DECL_FMAL == 0
306 extern long double fmal(long double x, long double y, long double z);
307 #endif
308 #if HAVE_DECL_FABSL == 0
309 extern long double fabsl(long double);
310 #endif
311 #if HAVE_DECL_SQRTL == 0
312 extern long double sqrtl(long double);
313 #endif
314 #if HAVE_DECL_CBRTL == 0
315 extern long double cbrtl(long double);
316 #endif
317 #if HAVE_DECL_HYPOTL == 0
318 extern long double hypotl(long double, long double);
319 #endif
320 #if HAVE_DECL_EXPL == 0
321 extern long double expl(long double);
322 #endif
323 #if HAVE_DECL_EXP2L == 0
324 extern long double exp2l(long double);
325 #endif
326 #if HAVE_DECL_EXPM1L == 0
327 extern long double expm1l(long double);
328 #endif
329 #if HAVE_DECL_LOGL == 0
330 extern long double logl(long double);
331 #endif
332 #if HAVE_DECL_LOG2L == 0
333 extern long double log2l(long double);
334 #endif
335 #if HAVE_DECL_LOG10L == 0
336 extern long double log10l(long double);
337 #endif
338 #if HAVE_DECL_LOG1PL == 0
339 extern long double log1pl(long double);
340 #endif
341 #if HAVE_DECL_LOGBL == 0
342 extern long double logbl(long double);
343 #endif
344 #if HAVE_DECL_ILOGBL == 0
345 extern int ilogbl(long double);
346 #endif
347 #if HAVE_DECL_MODFL == 0
348 extern long double modfl(long double, long double *);
349 #endif
350 #if HAVE_DECL_FREXPL == 0
351 extern long double frexpl(long double, int *);
352 #endif
353 #if HAVE_DECL_LDEXPL == 0
354 extern long double ldexpl(long double, int);
355 #endif
356 #if HAVE_DECL_SCALBNL == 0
357 extern long double scalbnl(long double, int);
358 #endif
359 #if HAVE_DECL_SCALBLNL == 0
360 extern long double scalblnl(long double, long int);
361 #endif
362 #if HAVE_DECL_POWL == 0
363 extern long double powl(long double, long double);
364 #endif
365 #if HAVE_DECL_COSL == 0
366 extern long double cosl(long double);
367 #endif
368 #if HAVE_DECL_SINL == 0
369 extern long double sinl(long double);
370 #endif
371 #if HAVE_DECL_TANL == 0
372 extern long double tanl(long double);
373 #endif
374 #if HAVE_DECL_COSHL == 0
375 extern long double coshl(long double);
376 #endif
377 #if HAVE_DECL_SINHL == 0
378 extern long double sinhl(long double);
379 #endif
380 #if HAVE_DECL_TANHL == 0
381 extern long double tanhl(long double);
382 #endif
383 #if HAVE_DECL_ACOSL == 0
384 extern long double acosl(long double);
385 #endif
386 #if HAVE_DECL_ASINL == 0
387 extern long double asinl(long double);
388 #endif
389 #if HAVE_DECL_ATANL == 0
390 extern long double atanl(long double);
391 #endif
392 #if HAVE_DECL_ATAN2L == 0
393 extern long double atan2l(long double, long double);
394 #endif
395 #if HAVE_DECL_ACOSHL == 0
396 extern long double acoshl(long double);
397 #endif
398 #if HAVE_DECL_ASINHL == 0
399 extern long double asinhl(long double);
400 #endif
401 #if HAVE_DECL_ATANHL == 0
402 extern long double atanhl(long double);
403 #endif
404 #if HAVE_DECL_TGAMMAL == 0
405 extern long double tgammal(long double);
406 #endif
407 #if HAVE_DECL_LGAMMAL == 0
408 extern long double lgammal(long double);
409 #endif
410 #if HAVE_DECL_J0L == 0
411 extern long double j0l(long double);
412 #endif
413 #if HAVE_DECL_J1L == 0
414 extern long double j1l(long double);
415 #endif
416 #if HAVE_DECL_JNL == 0
417 extern long double jnl(int, long double);
418 #endif
419 #if HAVE_DECL_Y0L == 0
420 extern long double y0l(long double);
421 #endif
422 #if HAVE_DECL_Y1L == 0
423 extern long double y1l(long double);
424 #endif
425 #if HAVE_DECL_YNL == 0
426 extern long double ynl(int, long double);
427 #endif
428 #if HAVE_DECL_ERFL == 0
429 extern long double erfl(long double);
430 #endif
431 #if HAVE_DECL_ERFCL == 0
432 extern long double erfcl(long double);
433 #endif
434 #if HAVE_DECL_CREALL == 0
435 extern long double creall(long double _Complex z);
436 #endif
437 #if HAVE_DECL_CIMAGL == 0
438 extern long double cimagl(long double _Complex z);
439 #endif
440 #if HAVE_DECL_CABSL == 0
441 extern long double cabsl(long double _Complex z);
442 #endif
443 #if HAVE_DECL_CARGL == 0
444 extern long double cargl(long double _Complex z);
445 #endif
446 #if HAVE_DECL_CONJL == 0
447 extern long double _Complex conjl(long double _Complex z);
448 #endif
449 #if HAVE_DECL_CPROJL == 0
450 extern long double _Complex cprojl(long double _Complex z);
451 #endif
452 #if HAVE_DECL_CSQRTL == 0
453 extern long double _Complex csqrtl(long double _Complex z);
454 #endif
455 #if HAVE_DECL_CEXPL == 0
456 extern long double _Complex cexpl(long double _Complex z);
457 #endif
458 #if HAVE_DECL_CLOGL == 0
459 extern long double _Complex clogl(long double _Complex z);
460 #endif
461 #if HAVE_DECL_CPOWL == 0
462 extern long double _Complex cpowl(long double _Complex z, long double _Complex w);
463 #endif
464 #if HAVE_DECL_CSINL == 0
465 extern long double _Complex csinl(long double _Complex z);
466 #endif
467 #if HAVE_DECL_CCOSL == 0
468 extern long double _Complex ccosl(long double _Complex z);
469 #endif
470 #if HAVE_DECL_CTANL == 0
471 extern long double _Complex ctanl(long double _Complex z);
472 #endif
473 #if HAVE_DECL_CASINL == 0
474 extern long double _Complex casinl(long double _Complex z);
475 #endif
476 #if HAVE_DECL_CACOSL == 0
477 extern long double _Complex cacosl(long double _Complex z);
478 #endif
479 #if HAVE_DECL_CATANL == 0
480 extern long double _Complex catanl(long double _Complex z);
481 #endif
482 #if HAVE_DECL_CSINHL == 0
483 extern long double _Complex csinhl(long double _Complex z);
484 #endif
485 #if HAVE_DECL_CCOSHL == 0
486 extern long double _Complex ccoshl(long double _Complex z);
487 #endif
488 #if HAVE_DECL_CTANHL == 0
489 extern long double _Complex ctanhl(long double _Complex z);
490 #endif
491 #if HAVE_DECL_CASINHL == 0
492 extern long double _Complex casinhl(long double _Complex z);
493 #endif
494 #if HAVE_DECL_CACOSHL == 0
495 extern long double _Complex cacoshl(long double _Complex z);
496 #endif
497 #if HAVE_DECL_CATANHL == 0
498 extern long double _Complex catanhl(long double _Complex z);
499 #endif
500 #define COPYSIGN copysignl
501 #define NEXTAFTER nextafterl
502 #define MKNAN nanl
503 #define CEIL ceill
504 #define FLOOR floorl
505 #define NEARBYINT nearbyintl
506 #define RINT rintl
507 #define ROUND roundl
508 #define LRINT lrintl
509 #define LROUND lroundl
510 #define LLRINT llrintl
511 #define LLROUND llroundl
512 #define TRUNC truncl
513 #define FMOD fmodl
514 #define REMAINDER remainderl
515 #define REMQUO remquol
516 #define FDIM fdiml
517 #define FMAX fmaxl
518 #define FMIN fminl
519 #define FFMA fmal
520 #define FABS fabsl
521 #define SQRT sqrtl
522 #define CBRT cbrtl
523 #define HYPOT hypotl
524 #define EXP expl
525 #define EXP2 exp2l
526 #define EXPM1 expm1l
527 #define LOG logl
528 #define LOG2 log2l
529 #define LOG10 log10l
530 #define LOG1P log1pl
531 #define LOGB logbl
532 #define ILOGB ilogbl
533 #define MODF modfl
534 #define FREXP frexpl
535 #define LDEXP ldexpl
536 #define SCALBN scalbnl
537 #define SCALBLN scalblnl
538 #define POW powl
539 #define COS cosl
540 #define SIN sinl
541 #define TAN tanl
542 #define COSH coshl
543 #define SINH sinhl
544 #define TANH tanhl
545 #define ACOS acosl
546 #define ASIN asinl
547 #define ATAN atanl
548 #define ATAN2 atan2l
549 #define ACOSH acoshl
550 #define ASINH asinhl
551 #define ATANH atanhl
552 #define TGAMMA tgammal
553 #define LGAMMA lgammal
554 #define J0 j0l
555 #define J1 j1l
556 #define JN jnl
557 #define Y0 y0l
558 #define Y1 y1l
559 #define YN ynl
560 #define ERF erfl
561 #define ERFC erfcl
562 #define CREAL creall
563 #define CIMAG cimagl
564 #define CABS cabsl
565 #define CARG cargl
566 #define CONJ conjl
567 #define CPROJ cprojl
568 #define CSQRT csqrtl
569 #define CEXP cexpl
570 #define CLOG clogl
571 #define CPOW cpowl
572 #define CSIN csinl
573 #define CCOS ccosl
574 #define CTAN ctanl
575 #define CASIN casinl
576 #define CACOS cacosl
577 #define CATAN catanl
578 #define CSINH csinhl
579 #define CCOSH ccoshl
580 #define CTANH ctanhl
581 #define CASINH casinhl
582 #define CACOSH cacoshl
583 #define CATANH catanhl
584 #elif defined(NFFT_SINGLE)
585 #if HAVE_DECL_COPYSIGNF == 0
586 extern float copysignf(float, float);
587 #endif
588 #if HAVE_DECL_NEXTAFTERF == 0
589 extern float nextafterf(float, float);
590 #endif
591 #if HAVE_DECL_NANF == 0
592 extern float nanf(const char *tag);
593 #endif
594 #if HAVE_DECL_CEILF == 0
595 extern float ceilf(float);
596 #endif
597 #if HAVE_DECL_FLOORF == 0
598 extern float floorf(float);
599 #endif
600 #if HAVE_DECL_NEARBYINTF == 0
601 extern float nearbyintf(float);
602 #endif
603 #if HAVE_DECL_RINTF == 0
604 extern float rintf(float);
605 #endif
606 #if HAVE_DECL_ROUNDF == 0
607 extern float roundf(float);
608 #endif
609 #if HAVE_DECL_LRINTF == 0
610 extern long int lrintf(float);
611 #endif
612 #if HAVE_DECL_LROUNDF == 0
613 extern long int lroundf(float);
614 #endif
615 #if HAVE_DECL_LLRINTF == 0
616 extern long long int llrintf(float);
617 #endif
618 #if HAVE_DECL_LLROUNDF == 0
619 extern long long int llroundf(float);
620 #endif
621 #if HAVE_DECL_TRUNCF == 0
622 extern float truncf(float);
623 #endif
624 #if HAVE_DECL_FMODF == 0
625 extern float fmodf(float, float);
626 #endif
627 #if HAVE_DECL_REMAINDERF == 0
628 extern float remainderf(float, float);
629 #endif
630 #if HAVE_DECL_REMQUOF == 0
631 extern float remquof(float x, float y, int *);
632 #endif
633 #if HAVE_DECL_FDIMF == 0
634 extern float fdimf(float, float);
635 #endif
636 #if HAVE_DECL_FMAXF == 0
637 extern float fmaxf(float, float);
638 #endif
639 #if HAVE_DECL_FMINF == 0
640 extern float fminf(float, float);
641 #endif
642 #if HAVE_DECL_FMAF == 0
643 extern float fmaf(float x, float y, float z);
644 #endif
645 #if HAVE_DECL_FABSF == 0
646 extern float fabsf(float);
647 #endif
648 #if HAVE_DECL_SQRTF == 0
649 extern float sqrtf(float);
650 #endif
651 #if HAVE_DECL_CBRTF == 0
652 extern float cbrtf(float);
653 #endif
654 #if HAVE_DECL_HYPOTF == 0
655 extern float hypotf(float, float);
656 #endif
657 #if HAVE_DECL_EXPF == 0
658 extern float expf(float);
659 #endif
660 #if HAVE_DECL_EXP2F == 0
661 extern float exp2f(float);
662 #endif
663 #if HAVE_DECL_EXPM1F == 0
664 extern float expm1f(float);
665 #endif
666 #if HAVE_DECL_LOGF == 0
667 extern float logf(float);
668 #endif
669 #if HAVE_DECL_LOG2F == 0
670 extern float log2f(float);
671 #endif
672 #if HAVE_DECL_LOG10F == 0
673 extern float log10f(float);
674 #endif
675 #if HAVE_DECL_LOG1PF == 0
676 extern float log1pf(float);
677 #endif
678 #if HAVE_DECL_LOGBF == 0
679 extern float logbf(float);
680 #endif
681 #if HAVE_DECL_ILOGBF == 0
682 extern int ilogbf(float);
683 #endif
684 #if HAVE_DECL_MODFF == 0
685 extern float modff(float, float *);
686 #endif
687 #if HAVE_DECL_FREXPF == 0
688 extern float frexpf(float, int *);
689 #endif
690 #if HAVE_DECL_LDEXPF == 0
691 extern float ldexpf(float, int);
692 #endif
693 #if HAVE_DECL_SCALBNF == 0
694 extern float scalbnf(float, int);
695 #endif
696 #if HAVE_DECL_SCALBLNF == 0
697 extern float scalblnf(float, long int);
698 #endif
699 #if HAVE_DECL_POWF == 0
700 extern float powf(float, float);
701 #endif
702 #if HAVE_DECL_COSF == 0
703 extern float cosf(float);
704 #endif
705 #if HAVE_DECL_SINF == 0
706 extern float sinf(float);
707 #endif
708 #if HAVE_DECL_TANF == 0
709 extern float tanf(float);
710 #endif
711 #if HAVE_DECL_COSHF == 0
712 extern float coshf(float);
713 #endif
714 #if HAVE_DECL_SINHF == 0
715 extern float sinhf(float);
716 #endif
717 #if HAVE_DECL_TANHF == 0
718 extern float tanhf(float);
719 #endif
720 #if HAVE_DECL_ACOSF == 0
721 extern float acosf(float);
722 #endif
723 #if HAVE_DECL_ASINF == 0
724 extern float asinf(float);
725 #endif
726 #if HAVE_DECL_ATANF == 0
727 extern float atanf(float);
728 #endif
729 #if HAVE_DECL_ATAN2F == 0
730 extern float atan2f(float, float);
731 #endif
732 #if HAVE_DECL_ACOSHF == 0
733 extern float acoshf(float);
734 #endif
735 #if HAVE_DECL_ASINHF == 0
736 extern float asinhf(float);
737 #endif
738 #if HAVE_DECL_ATANHF == 0
739 extern float atanhf(float);
740 #endif
741 #if HAVE_DECL_TGAMMAF == 0
742 extern float tgammaf(float);
743 #endif
744 #if HAVE_DECL_LGAMMAF == 0
745 extern float lgammaf(float);
746 #endif
747 #if HAVE_DECL_J0F == 0
748 extern float j0f(float);
749 #endif
750 #if HAVE_DECL_J1F == 0
751 extern float j1f(float);
752 #endif
753 #if HAVE_DECL_JNF == 0
754 extern float jnf(int, float);
755 #endif
756 #if HAVE_DECL_Y0F == 0
757 extern float y0f(float);
758 #endif
759 #if HAVE_DECL_Y1F == 0
760 extern float y1f(float);
761 #endif
762 #if HAVE_DECL_YNF == 0
763 extern float ynf(int, float);
764 #endif
765 #if HAVE_DECL_ERFF == 0
766 extern float erff(float);
767 #endif
768 #if HAVE_DECL_ERFCF == 0
769 extern float erfcf(float);
770 #endif
771 #if HAVE_DECL_CREALF == 0
772 extern float crealf(float _Complex z);
773 #endif
774 #if HAVE_DECL_CIMAGF == 0
775 extern float cimagf(float _Complex z);
776 #endif
777 #if HAVE_DECL_CABSF == 0
778 extern float cabsf(float _Complex z);
779 #endif
780 #if HAVE_DECL_CARGF == 0
781 extern float cargf(float _Complex z);
782 #endif
783 #if HAVE_DECL_CONJF == 0
784 extern float _Complex conjf(float _Complex z);
785 #endif
786 #if HAVE_DECL_CPROJF == 0
787 extern float _Complex cprojf(float _Complex z);
788 #endif
789 #if HAVE_DECL_CSQRTF == 0
790 extern float _Complex csqrtf(float _Complex z);
791 #endif
792 #if HAVE_DECL_CEXPF == 0
793 extern float _Complex cexpf(float _Complex z);
794 #endif
795 #if HAVE_DECL_CLOGF == 0
796 extern float _Complex clogf(float _Complex z);
797 #endif
798 #if HAVE_DECL_CPOWF == 0
799 extern float _Complex cpowf(float _Complex z, float _Complex w);
800 #endif
801 #if HAVE_DECL_CSINF == 0
802 extern float _Complex csinf(float _Complex z);
803 #endif
804 #if HAVE_DECL_CCOSF == 0
805 extern float _Complex ccosf(float _Complex z);
806 #endif
807 #if HAVE_DECL_CTANF == 0
808 extern float _Complex ctanf(float _Complex z);
809 #endif
810 #if HAVE_DECL_CASINF == 0
811 extern float _Complex casinf(float _Complex z);
812 #endif
813 #if HAVE_DECL_CACOSF == 0
814 extern float _Complex cacosf(float _Complex z);
815 #endif
816 #if HAVE_DECL_CATANF == 0
817 extern float _Complex catanf(float _Complex z);
818 #endif
819 #if HAVE_DECL_CSINHF == 0
820 extern float _Complex csinhf(float _Complex z);
821 #endif
822 #if HAVE_DECL_CCOSHF == 0
823 extern float _Complex ccoshf(float _Complex z);
824 #endif
825 #if HAVE_DECL_CTANHF == 0
826 extern float _Complex ctanhf(float _Complex z);
827 #endif
828 #if HAVE_DECL_CASINHF == 0
829 extern float _Complex casinhf(float _Complex z);
830 #endif
831 #if HAVE_DECL_CACOSHF == 0
832 extern float _Complex cacoshf(float _Complex z);
833 #endif
834 #if HAVE_DECL_CATANHF == 0
835 extern float _Complex catanhf(float _Complex z);
836 #endif
837 #define COPYSIGN copysignf
838 #define NEXTAFTER nextafterf
839 #define MKNAN nanf
840 #define CEIL ceilf
841 #define FLOOR floorf
842 #define NEARBYINT nearbyintf
843 #define RINT rintf
844 #define ROUND roundf
845 #define LRINT lrintf
846 #define LROUND lroundf
847 #define LLRINT llrintf
848 #define LLROUND llroundf
849 #define TRUNC truncf
850 #define FMOD fmodf
851 #define REMAINDER remainderf
852 #define REMQUO remquof
853 #define FDIM fdimf
854 #define FMAX fmaxf
855 #define FMIN fminf
856 #define FFMA fmaf
857 #define FABS fabsf
858 #define SQRT sqrtf
859 #define CBRT cbrtf
860 #define HYPOT hypotf
861 #define EXP expf
862 #define EXP2 exp2f
863 #define EXPM1 expm1f
864 #define LOG logf
865 #define LOG2 log2f
866 #define LOG10 log10f
867 #define LOG1P log1pf
868 #define LOGB logbf
869 #define ILOGB ilogbf
870 #define MODF modff
871 #define FREXP frexpf
872 #define LDEXP ldexpf
873 #define SCALBN scalbnf
874 #define SCALBLN scalblnf
875 #define POW powf
876 #define COS cosf
877 #define SIN sinf
878 #define TAN tanf
879 #define COSH coshf
880 #define SINH sinhf
881 #define TANH tanhf
882 #define ACOS acosf
883 #define ASIN asinf
884 #define ATAN atanf
885 #define ATAN2 atan2f
886 #define ACOSH acoshf
887 #define ASINH asinhf
888 #define ATANH atanhf
889 #define TGAMMA tgammaf
890 #define LGAMMA lgammaf
891 #define J0 j0f
892 #define J1 j1f
893 #define JN jnf
894 #define Y0 y0f
895 #define Y1 y1f
896 #define YN ynf
897 #define ERF erff
898 #define ERFC erfcf
899 #define CREAL crealf
900 #define CIMAG cimagf
901 #define CABS cabsf
902 #define CARG cargf
903 #define CONJ conjf
904 #define CPROJ cprojf
905 #define CSQRT csqrtf
906 #define CEXP cexpf
907 #define CLOG clogf
908 #define CPOW cpowf
909 #define CSIN csinf
910 #define CCOS ccosf
911 #define CTAN ctanf
912 #define CASIN casinf
913 #define CACOS cacosf
914 #define CATAN catanf
915 #define CSINH csinhf
916 #define CCOSH ccoshf
917 #define CTANH ctanhf
918 #define CASINH casinhf
919 #define CACOSH cacoshf
920 #define CATANH catanhf
921 #else
922 #if HAVE_DECL_COPYSIGN == 0
923 extern double copysign(double, double);
924 #endif
925 #if HAVE_DECL_NEXTAFTER == 0
926 extern double nextafter(double, double);
927 #endif
928 #if HAVE_DECL_NAN == 0
929 extern double nan(const char *tag);
930 #endif
931 #if HAVE_DECL_CEIL == 0
932 extern double ceil(double);
933 #endif
934 #if HAVE_DECL_FLOOR == 0
935 extern double floor(double);
936 #endif
937 #if HAVE_DECL_NEARBYINT == 0
938 extern double nearbyint(double);
939 #endif
940 #if HAVE_DECL_RINT == 0
941 extern double rint(double);
942 #endif
943 #if HAVE_DECL_ROUND == 0
944 extern double round(double);
945 #endif
946 #if HAVE_DECL_LRINT == 0
947 extern long int lrint(double);
948 #endif
949 #if HAVE_DECL_LROUND == 0
950 extern long int lround(double);
951 #endif
952 #if HAVE_DECL_LLRINT == 0
953 extern long long int llrint(double);
954 #endif
955 #if HAVE_DECL_LLROUND == 0
956 extern long long int llround(double);
957 #endif
958 #if HAVE_DECL_TRUNC == 0
959 extern double trunc(double);
960 #endif
961 #if HAVE_DECL_FMOD == 0
962 extern double fmod(double, double);
963 #endif
964 #if HAVE_DECL_REMAINDER == 0
965 extern double remainder(double, double);
966 #endif
967 #if HAVE_DECL_REMQUO == 0
968 extern double remquo(double x, double y, int *);
969 #endif
970 #if HAVE_DECL_FDIM == 0
971 extern double fdim(double, double);
972 #endif
973 #if HAVE_DECL_FMAX == 0
974 extern double fmax(double, double);
975 #endif
976 #if HAVE_DECL_FMIN == 0
977 extern double fmin(double, double);
978 #endif
979 #if HAVE_DECL_FMA == 0
980 extern double fma(double x, double y, double z);
981 #endif
982 #if HAVE_DECL_FABS == 0
983 extern double fabs(double);
984 #endif
985 #if HAVE_DECL_SQRT == 0
986 extern double sqrt(double);
987 #endif
988 #if HAVE_DECL_CBRT == 0
989 extern double cbrt(double);
990 #endif
991 #if HAVE_DECL_HYPOT == 0
992 extern double hypot(double, double);
993 #endif
994 #if HAVE_DECL_EXP == 0
995 extern double exp(double);
996 #endif
997 #if HAVE_DECL_EXP2 == 0
998 extern double exp2(double);
999 #endif
1000 #if HAVE_DECL_EXPM1 == 0
1001 extern double expm1(double);
1002 #endif
1003 #if HAVE_DECL_LOG == 0
1004 extern double log(double);
1005 #endif
1006 #if HAVE_DECL_LOG2 == 0
1007 extern double log2(double);
1008 #endif
1009 #if HAVE_DECL_LOG10 == 0
1010 extern double log10(double);
1011 #endif
1012 #if HAVE_DECL_LOG1P == 0
1013 extern double log1p(double);
1014 #endif
1015 #if HAVE_DECL_LOGB == 0
1016 extern double logb(double);
1017 #endif
1018 #if HAVE_DECL_ILOGB == 0
1019 extern int ilogb(double);
1020 #endif
1021 #if HAVE_DECL_MODF == 0
1022 extern double modf(double, double *);
1023 #endif
1024 #if HAVE_DECL_FREXP == 0
1025 extern double frexp(double, int *);
1026 #endif
1027 #if HAVE_DECL_LDEXP == 0
1028 extern double ldexp(double, int);
1029 #endif
1030 #if HAVE_DECL_SCALBN == 0
1031 extern double scalbn(double, int);
1032 #endif
1033 #if HAVE_DECL_SCALBLN == 0
1034 extern double scalbln(double, long int);
1035 #endif
1036 #if HAVE_DECL_POW == 0
1037 extern double pow(double, double);
1038 #endif
1039 #if HAVE_DECL_COS == 0
1040 extern double cos(double);
1041 #endif
1042 #if HAVE_DECL_SIN == 0
1043 extern double sin(double);
1044 #endif
1045 #if HAVE_DECL_TAN == 0
1046 extern double tan(double);
1047 #endif
1048 #if HAVE_DECL_COSH == 0
1049 extern double cosh(double);
1050 #endif
1051 #if HAVE_DECL_SINH == 0
1052 extern double sinh(double);
1053 #endif
1054 #if HAVE_DECL_TANH == 0
1055 extern double tanh(double);
1056 #endif
1057 #if HAVE_DECL_ACOS == 0
1058 extern double acos(double);
1059 #endif
1060 #if HAVE_DECL_ASIN == 0
1061 extern double asin(double);
1062 #endif
1063 #if HAVE_DECL_ATAN == 0
1064 extern double atan(double);
1065 #endif
1066 #if HAVE_DECL_ATAN2 == 0
1067 extern double atan2(double, double);
1068 #endif
1069 #if HAVE_DECL_ACOSH == 0
1070 extern double acosh(double);
1071 #endif
1072 #if HAVE_DECL_ASINH == 0
1073 extern double asinh(double);
1074 #endif
1075 #if HAVE_DECL_ATANH == 0
1076 extern double atanh(double);
1077 #endif
1078 #if HAVE_DECL_TGAMMA == 0
1079 extern double tgamma(double);
1080 #endif
1081 #if HAVE_DECL_LGAMMA == 0
1082 extern double lgamma(double);
1083 #endif
1084 #if HAVE_DECL_J0 == 0
1085 extern double j0(double);
1086 #endif
1087 #if HAVE_DECL_J1 == 0
1088 extern double j1(double);
1089 #endif
1090 #if HAVE_DECL_JN == 0
1091 extern double jn(int, double);
1092 #endif
1093 #if HAVE_DECL_Y0 == 0
1094 extern double y0(double);
1095 #endif
1096 #if HAVE_DECL_Y1 == 0
1097 extern double y1(double);
1098 #endif
1099 #if HAVE_DECL_YN == 0
1100 extern double yn(int, double);
1101 #endif
1102 #if HAVE_DECL_ERF == 0
1103 extern double erf(double);
1104 #endif
1105 #if HAVE_DECL_ERFC == 0
1106 extern double erfc(double);
1107 #endif
1108 #if HAVE_DECL_CREAL == 0
1109 extern double creal(double _Complex z);
1110 #endif
1111 #if HAVE_DECL_CIMAG == 0
1112 extern double cimag(double _Complex z);
1113 #endif
1114 #if HAVE_DECL_CABS == 0
1115 extern double cabs(double _Complex z);
1116 #endif
1117 #if HAVE_DECL_CARG == 0
1118 extern double carg(double _Complex z);
1119 #endif
1120 #if HAVE_DECL_CONJ == 0
1121 extern double _Complex conj(double _Complex z);
1122 #endif
1123 #if HAVE_DECL_CPROJ == 0
1124 extern double _Complex cproj(double _Complex z);
1125 #endif
1126 #if HAVE_DECL_CSQRT == 0
1127 extern double _Complex csqrt(double _Complex z);
1128 #endif
1129 #if HAVE_DECL_CEXP == 0
1130 extern double _Complex cexp(double _Complex z);
1131 #endif
1132 #if HAVE_DECL_CLOG == 0
1133 extern double _Complex clog(double _Complex z);
1134 #endif
1135 #if HAVE_DECL_CPOW == 0
1136 extern double _Complex cpow(double _Complex z, double _Complex w);
1137 #endif
1138 #if HAVE_DECL_CSIN == 0
1139 extern double _Complex csin(double _Complex z);
1140 #endif
1141 #if HAVE_DECL_CCOS == 0
1142 extern double _Complex ccos(double _Complex z);
1143 #endif
1144 #if HAVE_DECL_CTAN == 0
1145 extern double _Complex ctan(double _Complex z);
1146 #endif
1147 #if HAVE_DECL_CASIN == 0
1148 extern double _Complex casin(double _Complex z);
1149 #endif
1150 #if HAVE_DECL_CACOS == 0
1151 extern double _Complex cacos(double _Complex z);
1152 #endif
1153 #if HAVE_DECL_CATAN == 0
1154 extern double _Complex catan(double _Complex z);
1155 #endif
1156 #if HAVE_DECL_CSINH == 0
1157 extern double _Complex csinh(double _Complex z);
1158 #endif
1159 #if HAVE_DECL_CCOSH == 0
1160 extern double _Complex ccosh(double _Complex z);
1161 #endif
1162 #if HAVE_DECL_CTANH == 0
1163 extern double _Complex ctanh(double _Complex z);
1164 #endif
1165 #if HAVE_DECL_CASINH == 0
1166 extern double _Complex casinh(double _Complex z);
1167 #endif
1168 #if HAVE_DECL_CACOSH == 0
1169 extern double _Complex cacosh(double _Complex z);
1170 #endif
1171 #if HAVE_DECL_CATANH == 0
1172 extern double _Complex catanh(double _Complex z);
1173 #endif
1174 #define COPYSIGN copysign
1175 #define NEXTAFTER nextafter
1176 #define MKNAN nan
1177 #define CEIL ceil
1178 #define FLOOR floor
1179 #define NEARBYINT nearbyint
1180 #define RINT rint
1181 #define ROUND round
1182 #define LRINT lrint
1183 #define LROUND lround
1184 #define LLRINT llrint
1185 #define LLROUND llround
1186 #define TRUNC trunc
1187 #define FMOD fmod
1188 #define REMAINDER remainder
1189 #define REMQUO remquo
1190 #define FDIM fdim
1191 #define FMAX fmax
1192 #define FMIN fmin
1193 #define FFMA fma
1194 #define FABS fabs
1195 #define SQRT sqrt
1196 #define CBRT cbrt
1197 #define HYPOT hypot
1198 #define EXP exp
1199 #define EXP2 exp2
1200 #define EXPM1 expm1
1201 #define LOG log
1202 #define LOG2 log2
1203 #define LOG10 log10
1204 #define LOG1P log1p
1205 #define LOGB logb
1206 #define ILOGB ilogb
1207 #define MODF modf
1208 #define FREXP frexp
1209 #define LDEXP ldexp
1210 #define SCALBN scalbn
1211 #define SCALBLN scalbln
1212 #define POW pow
1213 #define COS cos
1214 #define SIN sin
1215 #define TAN tan
1216 #define COSH cosh
1217 #define SINH sinh
1218 #define TANH tanh
1219 #define ACOS acos
1220 #define ASIN asin
1221 #define ATAN atan
1222 #define ATAN2 atan2
1223 #define ACOSH acosh
1224 #define ASINH asinh
1225 #define ATANH atanh
1226 #define TGAMMA tgamma
1227 #define LGAMMA lgamma
1228 #define J0 j0
1229 #define J1 j1
1230 #define JN jn
1231 #define Y0 y0
1232 #define Y1 y1
1233 #define YN yn
1234 #define ERF erf
1235 #define ERFC erfc
1236 #define CREAL creal
1237 #define CIMAG cimag
1238 #define CABS cabs
1239 #define CARG carg
1240 #define CONJ conj
1241 #define CPROJ cproj
1242 #define CSQRT csqrt
1243 #define CEXP cexp
1244 #define CLOG clog
1245 #define CPOW cpow
1246 #define CSIN csin
1247 #define CCOS ccos
1248 #define CTAN ctan
1249 #define CASIN casin
1250 #define CACOS cacos
1251 #define CATAN catan
1252 #define CSINH csinh
1253 #define CCOSH ccosh
1254 #define CTANH ctanh
1255 #define CASINH casinh
1256 #define CACOSH cacosh
1257 #define CATANH catanh
1258 #endif
1259 
1260 #if defined(NFFT_LDOUBLE)
1261  #define EPSILON LDBL_EPSILON//4.0E-31L
1262  #define MANT_DIG LDBL_MANT_DIG
1263  #define MIN_EXP LDBL_MIN_EXP
1264  #define MAX_EXP LDBL_MAX_EXP
1265 #elif defined(NFFT_SINGLE)
1266  #define EPSILON FLT_EPSILON
1267  #define MANT_DIG FLT_MANT_DIG
1268  #define MIN_EXP FLT_MIN_EXP
1269  #define MAX_EXP FLT_MAX_EXP
1270 #else
1271  #define EPSILON DBL_EPSILON
1272  #define MANT_DIG DBL_MANT_DIG
1273  #define MIN_EXP DBL_MIN_EXP
1274  #define MAX_EXP DBL_MAX_EXP
1275 #endif
1276 
1277 #if defined(FLT_ROUND)
1278  #if FLT_ROUND != -1
1279  #define FLTROUND 1.0
1280  #else
1281  #define FLTROUND 0.0
1282  #endif
1283 #else
1284  #define FLTROUND 0.0
1285 #endif
1286 
1287 #if HAVE_DECL_DRAND48 == 0
1288  extern double drand48(void);
1289 #endif
1290 #if HAVE_DECL_SRAND48 == 0
1291  extern void srand48(long int);
1292 #endif
1293 #define R_RADIX FLT_RADIX
1294 #define II _Complex_I
1295 
1296 /* format strings */
1297 #if defined(NFFT_LDOUBLE)
1298 # define __FGS__ "Lg"
1299 # define __FES__ "LE"
1300 # define __FE__ "% 36.32LE"
1301 # define __FI__ "%Lf"
1302 # define __FIS__ "Lf"
1303 # define __FR__ "%Le"
1304 #elif defined(NFFT_SINGLE)
1305 # define __FGS__ "g"
1306 # define __FES__ "E"
1307 # define __FE__ "% 12.8E"
1308 # define __FI__ "%f"
1309 # define __FIS__ "f"
1310 # define __FR__ "%e"
1311 #else
1312 # define __FGS__ "lg"
1313 # define __FES__ "lE"
1314 # define __FE__ "% 20.16lE"
1315 # define __FI__ "%lf"
1316 # define __FIS__ "lf"
1317 # define __FR__ "%le"
1318 #endif
1319 
1320 #define TRUE 1
1321 #define FALSE 0
1322 
1323 #if defined(_WIN32) || defined(_WIN64)
1324 # define __D__ "%Id"
1325 #else
1326 # define __D__ "%td"
1327 #endif
1328 
1330 #define UNUSED(x) (void)x
1331 
1332 #ifdef HAVE_ALLOCA
1333  /* Use alloca if available. */
1334  #ifndef alloca
1335  #ifdef __GNUC__
1336  /* No alloca defined but can use GCC's builtin version. */
1337  #define alloca __builtin_alloca
1338  #else
1339  /* No alloca defined and not using GCC. */
1340  #ifdef _MSC_VER
1341  /* Using Microsoft's C compiler. Include header file and use _alloca
1342  * defined therein. */
1343  #include <malloc.h>
1344  #define alloca _alloca
1345  #else
1346  /* Also not using Microsoft's C compiler. */
1347  #if HAVE_ALLOCA_H
1348  /* Alloca header is available. */
1349  #include <alloca.h>
1350  #else
1351  /* No alloca header available. */
1352  #ifdef _AIX
1353  /* We're using the AIX C compiler. Use pragma. */
1354  #pragma alloca
1355  #else
1356  /* Not using AIX compiler. */
1357  #ifndef alloca /* HP's cc +Olibcalls predefines alloca. */
1358  void *alloca(size_t);
1359  #endif
1360  #endif
1361  #endif
1362  #endif
1363  #endif
1364  #endif
1365  /* So we have alloca. */
1366  #define STACK_MALLOC(T, p, x) p = (T)alloca(x)
1367  #define STACK_FREE(x) /* Nothing. Cleanup done automatically. */
1368 #else /* ! HAVE_ALLOCA */
1369  /* Use malloc instead of alloca. So we allocate memory on the heap instead of
1370  * on the stack which is slower. */
1371  #define STACK_MALLOC(T, p, x) p = (T)Y(malloc)(x)
1372  #define STACK_FREE(x) Y(free)(x)
1373 #endif /* ! HAVE_ALLOCA */
1374 
1376 R Y(elapsed_seconds)(ticks t1, ticks t0);
1377 
1379 #define UNUSED(x) (void)x
1380 
1387 #ifdef MEASURE_TIME
1388  int MEASURE_TIME_r;
1389  double MEASURE_TIME_tt;
1390  ticks MEASURE_TIME_t0, MEASURE_TIME_t1;
1391 
1392 #define TIC(a) \
1393  ths->MEASURE_TIME_t[(a)]=0; \
1394  MEASURE_TIME_r=0; \
1395  /* DISABLED LOOP due to code blocks causing segfault when repeatedly run */ \
1396  /*while(ths->MEASURE_TIME_t[(a)]<0.01)*/ \
1397  { \
1398  MEASURE_TIME_r++; \
1399  MEASURE_TIME_t0 = getticks(); \
1400 
1401 /* THE MEASURED FUNCTION IS CALLED REPEATEDLY */
1402 
1403 #define TOC(a) \
1404  MEASURE_TIME_t1 = getticks(); \
1405  MEASURE_TIME_tt = Y(elapsed_seconds)(MEASURE_TIME_t1,MEASURE_TIME_t0);\
1406  ths->MEASURE_TIME_t[(a)]+=MEASURE_TIME_tt; \
1407  } \
1408  ths->MEASURE_TIME_t[(a)]/=MEASURE_TIME_r; \
1409 
1410 #else
1411 #define TIC(a)
1412 #define TOC(a)
1413 #endif
1414 
1415 #ifdef MEASURE_TIME_FFTW
1416 #define TIC_FFTW(a) TIC(a)
1417 #define TOC_FFTW(a) TOC(a)
1418 #else
1419 #define TIC_FFTW(a)
1420 #define TOC_FFTW(a)
1421 #endif
1422 
1423 /* sinc.c: */
1424 
1425 /* Sinus cardinalis. */
1426 R Y(sinc)(R x);
1427 
1428 /* lambda.c: */
1429 
1430 /* lambda(z, eps) = gamma(z + eps) / gamma(z + 1) */
1431 R Y(lambda)(R z, R eps);
1432 
1433 /* lambda2(mu, nu) = sqrt(gamma(mu + nu + 1) / (gamma(mu + 1) * gamma(nu + 1))) */
1434 R Y(lambda2)(R mu, R nu);
1435 
1436 /* bessel_i0.c: */
1437 R Y(bessel_i0)(R x);
1438 
1439 /* bspline.c: */
1440 R Y(bsplines)(const INT, const R x);
1441 
1442 /* float.c: */
1443 typedef enum {NFFT_EPSILON = 0, NFFT_SAFE__MIN = 1, NFFT_BASE = 2,
1444  NFFT_PRECISION = 3, NFFT_MANT_DIG = 4, NFFT_FLTROUND = 5, NFFT_E_MIN = 6,
1445  NFFT_R_MIN = 7, NFFT_E_MAX = 8, NFFT_R_MAX = 9} float_property;
1446 
1447 R Y(float_property)(float_property);
1448 R Y(prod_real)(R *vec, INT d);
1449 
1450 /* int.c: */
1451 INT Y(log2i)(const INT m);
1452 void Y(next_power_of_2_exp)(const INT N, INT *N2, INT *t);
1453 void Y(next_power_of_2_exp_int)(const int N, int *N2, int *t);
1454 
1455 /* error.c: */
1456 /* not used */ R Y(error_l_infty_double)(const R *x, const R *y, const INT n);
1457 /* not used */ R Y(error_l_infty_1_double)(const R *x, const R *y, const INT n, const R *z,
1458  const INT m);
1459 R Y(error_l_2_complex)(const C *x, const C *y, const INT n);
1460 /* not used */ R Y(error_l_2_double)(const R *x, const R *y, const INT n);
1461 
1462 /* sort.c: */
1463 void Y(sort_node_indices_radix_msdf)(INT n, INT *keys0, INT *keys1, INT rhigh);
1464 void Y(sort_node_indices_radix_lsdf)(INT n, INT *keys0, INT *keys1, INT rhigh);
1465 
1466 /* assert.c */
1467 void Y(assertion_failed)(const char *s, int line, const char *file);
1468 
1469 /* vector1.c */
1471 R Y(dot_double)(R *x, INT n);
1473 R Y(dot_w_complex)(C *x, R *w, INT n);
1475 R Y(dot_w_double)(R *x, R *w, INT n);
1477 R Y(dot_w_w2_complex)(C *x, R *w, R *w2, INT n);
1479 R Y(dot_w2_complex)(C *x, R *w2, INT n);
1480 
1481 /* vector2.c */
1483 void Y(cp_complex)(C *x, C *y, INT n);
1485 void Y(cp_double)(R *x, R *y, INT n);
1487 void Y(cp_a_complex)(C *x, R a, C *y, INT n);
1489 void Y(cp_a_double)(R *x, R a, R *y, INT n);
1491 void Y(cp_w_complex)(C *x, R *w, C *y, INT n);
1493 void Y(cp_w_double)(R *x, R *w, R *y, INT n);
1494 
1495 /* vector3.c */
1497 void Y(upd_axpy_double)(R *x, R a, R *y, INT n);
1499 void Y(upd_xpay_complex)(C *x, R a, C *y, INT n);
1501 void Y(upd_xpay_double)(R *x, R a, R *y, INT n);
1503 void Y(upd_axpby_complex)(C *x, R a, C *y, R b, INT n);
1505 void Y(upd_axpby_double)(R *x, R a, R *y, R b, INT n);
1507 void Y(upd_xpawy_complex)(C *x, R a, R *w, C *y, INT n);
1509 void Y(upd_xpawy_double)(R *x, R a, R *w, R *y, INT n);
1511 void Y(upd_axpwy_complex)(C *x, R a, R *w, C *y, INT n);
1513 void Y(upd_axpwy_double)(R *x, R a, R *w, R *y, INT n);
1514 
1515 /* voronoi.c */
1516 void Y(voronoi_weights_1d)(R *w, R *x, const INT M);
1517 
1518 /* damp.c */
1523 R Y(modified_fejer)(const INT N, const INT kk);
1525 R Y(modified_jackson2)(const INT N, const INT kk);
1527 R Y(modified_jackson4)(const INT N, const INT kk);
1529 R Y(modified_sobolev)(const R mu, const INT kk);
1531 R Y(modified_multiquadric)(const R mu, const R c, const INT kk);
1532 
1533 /* always check */
1534 #define CK(ex) \
1535  (void)((ex) || (Y(assertion_failed)(#ex, __LINE__, __FILE__), 0))
1536 
1537 #ifdef NFFT_DEBUG
1538  /* check only if debug enabled */
1539  #define A(ex) \
1540  (void)((ex) || (Y(assertion_failed)(#ex, __LINE__, __FILE__), 0))
1541 #else
1542  #define A(ex) /* nothing */
1543 #endif
1544 
1548 #endif