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