This file is indexed.

/usr/include/nfft3.h is in libnfft3-dev 3.2.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
/*
 * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/* $Id: nfft3.h 3896 2012-10-10 12:19:26Z tovo $ */

#ifndef __NFFT3_H__
#define __NFFT3_H__

/* module configuration */
#include "nfft3conf.h"

/* fftw_complex */
#include <fftw3.h>

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

#define NFFT_CONCAT(prefix, name) prefix ## name

/* IMPORTANT: for Windows compilers, you should add a line
 *   #define FFTW_DLL
 * here and in kernel/infft.h if you are compiling/using NFFT as a DLL, in order
 * to do the proper importing/exporting, or alternatively compile with
 * -DNFFT_DLL or the equivalent command-line flag. This is not necessary under
 * MinGW/Cygwin, where libtool does the imports/exports automatically. */
#if defined(NFFT_DLL) && (defined(_WIN32) || defined(__WIN32__))
  /* annoying Windows syntax for shared-library declarations */
#  if defined(COMPILING_NFFT) /* defined in api.h when compiling NFFT */
#    define NFFT_EXTERN extern __declspec(dllexport)
#  else /* user is calling NFFT; import symbol */
#    define NFFT_EXTERN extern __declspec(dllimport)
#  endif
#else
#  define NFFT_EXTERN extern
#endif

/* our own memory allocation and exit functions */
NFFT_EXTERN void *nfft_malloc(size_t n);
NFFT_EXTERN void nfft_free(void *p);
NFFT_EXTERN void nfft_die(char *s);

/* You can replace the hooks with your own, functions if necessary. We need this
 * for the Matlab interfaces etc. */
typedef void *(*nfft_malloc_type_function) (size_t n);
typedef void  (*nfft_free_type_function) (void *p);
typedef void  (*nfft_die_type_function) (const char *errString);
NFFT_EXTERN nfft_malloc_type_function nfft_malloc_hook;
NFFT_EXTERN nfft_free_type_function nfft_free_hook;
NFFT_EXTERN nfft_die_type_function nfft_die_hook;

/* members inherited by all plans */
#define MACRO_MV_PLAN(RC) \
  int N_total; /**< Total number of Fourier coefficients */\
  int M_total; /**< Total number of samples */\
  RC *f_hat; /**< Vector of Fourier coefficients, size is N_total * sizeof(RC) */\
  RC *f; /**< Vector of samples, size is M_total * sizeof(RC) */\
  void (*mv_trafo)(void*); /**< Pointer to the own transform */\
  void (*mv_adjoint)(void*); /**< Pointer to the own adjoint */

/* nfft */

/* name mangling macros */
#define NFFT_MANGLE_DOUBLE(name) NFFT_CONCAT(nfft_, name)
#define NFFT_MANGLE_FLOAT(name) NFFT_CONCAT(nfftf_, name)
#define NFFT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nfftl_, name)

/* huge second-order macro that defines prototypes for all nfft API functions.
 * We expand this macro for each supported precision.
 *   X: nfft name-mangling macro
 *   Y: fftw name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NFFT_DEFINE_API(X,Y,R,C) \
\
typedef struct \
{ \
  MACRO_MV_PLAN(C) \
} X(mv_plan_complex); \
\
typedef struct \
{ \
  MACRO_MV_PLAN(R) \
} X(mv_plan_double); \
\
typedef struct\
{\
  MACRO_MV_PLAN(C)\
\
  int d; /**< dimension aka rank */\
  int *N; /**< multi-bandwidth */\
  R *sigma; /**< oversampling-factor */\
  int *n; /**< FFTW length, equal to sigma*N, default is the power of 2 such
               that \f$2\le\sigma<4\f$ */\
  int n_total; /**< Total size of FFTW */\
  int m; /**< Cut-off parameter of the window function, default value is
               6 (KAISER_BESSEL),
               9 (SINC_POWER),
               11 (B_SPLINE),
               12 (GAUSSIAN) */\
  R *b; /**< Shape parameter of the window function */\
  int K; /**< Number of equispaced samples of the window function for \ref
              PRE_LIN_PSI */\
\
  unsigned nfft_flags; /**< Flags for precomputation, (de)allocation, and FFTW
                            usage, default setting is
                            PRE_PHI_HUT | PRE_PSI | MALLOC_X | MALLOC_F_HAT |
                            MALLOC_F | FFTW_INIT | FFT_OUT_OF_PLACE */\
\
  unsigned fftw_flags; /**< Flags for the FFTW, default is
                            FFTW_ESTIMATE | FFTW_DESTROY_INPUT */\
\
  R *x; /**< Nodes in time/spatial domain, size is \f$dM\f$ doubles */\
\
  double MEASURE_TIME_t[3]; /**< Measured time for each step if MEASURE_TIME is
    set */\
\
  /* internal use only */\
  Y(plan)  my_fftw_plan1; /**< Forward FFTW plan */\
  Y(plan)  my_fftw_plan2; /**< Backward FFTW plan */\
\
  R **c_phi_inv; /**< Precomputed data for the diagonal matrix \f$D\f$, size \
    is \f$N_0+\hdots+N_{d-1}\f$ doubles*/\
  R *psi; /**< Precomputed data for the sparse matrix \f$B\f$, size depends
                    on precomputation scheme */\
  int *psi_index_g; /**< Indices in source/target vector for \ref PRE_FULL_PSI */\
  int *psi_index_f; /**< Indices in source/target vector for \ref PRE_FULL_PSI */\
\
  C *g; /**< Oversampled vector of samples, size is \ref n_total double complex */\
  C *g_hat; /**< Zero-padded vector of Fourier coefficients, size is \ref n_total fftw_complex */\
  C *g1; /**< Input of fftw */\
  C *g2; /**< Output of fftw */\
\
  R *spline_coeffs; /**< Input for de Boor algorithm if B_SPLINE or SINC_POWER is defined */\
\
  int *index_x; /**< Index array for nodes x used when flag \ref NFFT_SORT_NODES is set */\
} X(plan); \
\
NFFT_EXTERN void X(trafo_direct)(X(plan) *ths);\
NFFT_EXTERN void X(adjoint_direct)(X(plan) *ths);\
NFFT_EXTERN void X(trafo)(X(plan) *ths);\
NFFT_EXTERN void X(trafo_1d)(X(plan) *ths);\
NFFT_EXTERN void X(trafo_2d)(X(plan) *ths);\
NFFT_EXTERN void X(trafo_3d)(X(plan) *ths);\
NFFT_EXTERN void X(adjoint)(X(plan) *ths);\
NFFT_EXTERN void X(adjoint_1d)(X(plan) *ths);\
NFFT_EXTERN void X(adjoint_2d)(X(plan) *ths);\
NFFT_EXTERN void X(adjoint_3d)(X(plan) *ths);\
NFFT_EXTERN void X(init_1d)(X(plan) *ths, int N1, int M);\
NFFT_EXTERN void X(init_2d)(X(plan) *ths, int N1, int N2, int M);\
NFFT_EXTERN void X(init_3d)(X(plan) *ths, int N1, int N2, int N3, int M);\
NFFT_EXTERN void X(init)(X(plan) *ths, int d, int *N, int M);\
NFFT_EXTERN void X(init_guru)(X(plan) *ths, int d, int *N, int M, int *n, \
  int m, unsigned nfft_flags, unsigned fftw_flags);\
NFFT_EXTERN void X(precompute_one_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_full_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_lin_psi)(X(plan) *ths);\
NFFT_EXTERN const char* X(check)(X(plan) *ths);\
NFFT_EXTERN void X(finalize)(X(plan) *ths);

/* nfft api */
NFFT_DEFINE_API(NFFT_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,float,fftwf_complex)
NFFT_DEFINE_API(NFFT_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,double,fftw_complex)
NFFT_DEFINE_API(NFFT_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,long double,fftwl_complex)

/* flags for init */
#define PRE_PHI_HUT      (1U<< 0)
#define FG_PSI           (1U<< 1)
#define PRE_LIN_PSI      (1U<< 2)
#define PRE_FG_PSI       (1U<< 3)
#define PRE_PSI          (1U<< 4)
#define PRE_FULL_PSI     (1U<< 5)
#define MALLOC_X         (1U<< 6)
#define MALLOC_F_HAT     (1U<< 7)
#define MALLOC_F         (1U<< 8)
#define FFT_OUT_OF_PLACE (1U<< 9)
#define FFTW_INIT        (1U<< 10)
#define NFFT_SORT_NODES  (1U<< 11)
#define NFFT_OMP_BLOCKWISE_ADJOINT (1U<<12)
#define PRE_ONE_PSI (PRE_LIN_PSI| PRE_FG_PSI| PRE_PSI| PRE_FULL_PSI)


/* nfct */

/* name mangling macros */
#define NFCT_MANGLE_DOUBLE(name) NFFT_CONCAT(nfct_, name)
#define NFCT_MANGLE_FLOAT(name) NFFT_CONCAT(nfctf_, name)
#define NFCT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nfctl_, name)

/* huge second-order macro that defines prototypes for all nfct API functions.
 * We expand this macro for each supported precision.
 *   X: nfct name-mangling macro
 *   Y: fftw name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NFCT_DEFINE_API(X,Y,R,C) \
typedef struct\
{\
  /* api */\
  MACRO_MV_PLAN(R)\
\
  int d; /**< dimension, rank */\
  int *N; /**< cut-off-frequencies (kernel) */\
  int *n; /**< length of DCT-I */\
  R *sigma; /**< oversampling-factor */\
  int m; /**< cut-off parameter in time-domain */\
\
  R nfct_full_psi_eps;\
  R *b; /**< shape parameters */\
\
  unsigned nfct_flags; /**< flags for precomputation, malloc */\
  unsigned fftw_flags; /**< flags for the fftw */\
\
  R *x; /**< nodes (in time/spatial domain)   */\
\
  double MEASURE_TIME_t[3]; /**< measured time for each step */\
\
  /* internal use only */\
  Y(plan)  my_fftw_r2r_plan; /**< fftw_plan */\
  Y(r2r_kind) *r2r_kind; /**< r2r transform type (DCT-I) */\
\
  R **c_phi_inv; /**< precomputed data, matrix D */\
  R *psi; /**< precomputed data, matrix B */\
  int size_psi; /**< only for thin B */\
  int *psi_index_g; /**< only for thin B */\
  int *psi_index_f; /**< only for thin B */\
\
  R *g;\
  R *g_hat;\
  R *g1; /**< input of fftw */\
  R *g2; /**< output of fftw */\
\
  R *spline_coeffs; /**< input for de Boor algorithm, if B_SPLINE or SINC_2m is defined   */\
} X(plan);\
\
NFFT_EXTERN void X(init_1d)(X(plan) *ths_plan, int N0, int M_total); \
NFFT_EXTERN void X(init_2d)(X(plan) *ths_plan, int N0, int N1, int M_total); \
NFFT_EXTERN void X(init_3d)(X(plan) *ths_plan, int N0, int N1, int N2, int M_total); \
NFFT_EXTERN void X(init)(X(plan) *ths_plan, int d, int *N, int M_total); \
NFFT_EXTERN void X(init_guru)(X(plan) *ths_plan, int d, int *N, int M_total, int *n, \
  int m, unsigned nfct_flags, unsigned fftw_flags); \
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan); \
NFFT_EXTERN R X(phi_hut)(X(plan) *ths_plan, int k, int d); \
NFFT_EXTERN R X(phi)(X(plan) *ths_plan, R x, int d);

#if defined(HAVE_NFCT)
/* nfct api */
NFCT_DEFINE_API(NFCT_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,float,fftwf_complex)
NFCT_DEFINE_API(NFCT_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,double,fftw_complex)
NFCT_DEFINE_API(NFCT_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* nfst */

/* name mangling macros */
#define NFST_MANGLE_DOUBLE(name) NFFT_CONCAT(nfst_, name)
#define NFST_MANGLE_FLOAT(name) NFFT_CONCAT(nfstf_, name)
#define NFST_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nfstl_, name)

/* huge second-order macro that defines prototypes for all nfct API functions.
 * We expand this macro for each supported precision.
 *   X: nfst name-mangling macro
 *   Y: fftw name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NFST_DEFINE_API(X,Y,R,C) \
typedef struct\
{\
  /* api */\
  MACRO_MV_PLAN(R)\
\
  int d; /**< dimension, rank */\
  int *N; /**< bandwidth */\
  int *n; /**< length of DST-1 */\
  R *sigma; /**< oversampling-factor */\
  int m; /**< cut-off parameter in time-domain */\
\
  R nfst_full_psi_eps;\
  R *b; /**< shape parameters */\
\
  unsigned nfst_flags; /**< flags for precomputation, malloc */\
  unsigned fftw_flags; /**< flags for the fftw */\
\
  R *x; /**< nodes (in time/spatial domain) */\
\
  double MEASURE_TIME_t[3]; /**< measured time for each step */\
\
  /* internal use only */\
  Y(plan)  my_fftw_r2r_plan; /**< fftw_plan forward */\
  Y(r2r_kind) *r2r_kind; /**< r2r transform type (dct-i) */\
\
  R **c_phi_inv; /**< precomputed data, matrix D */\
  R *psi; /**< precomputed data, matrix B */\
  int size_psi; /**< only for thin B */\
  int *psi_index_g; /**< only for thin B */\
  int *psi_index_f; /**< only for thin B */\
\
  R *g;\
  R *g_hat;\
  R *g1; /**< input of fftw */\
  R *g2; /**< output of fftw */\
\
  R *spline_coeffs; /**< input for de Boor algorithm, if B_SPLINE or SINC_2m is defined */\
} X(plan);\
\
NFFT_EXTERN void X(init_1d)(X(plan) *ths_plan, int N0, int M_total); \
NFFT_EXTERN void X(init_2d)(X(plan) *ths_plan, int N0, int N1, int M_total); \
NFFT_EXTERN void X(init_3d)(X(plan) *ths_plan, int N0, int N1, int N2, int M_total); \
NFFT_EXTERN void X(init)(X(plan) *ths_plan, int d, int *N, int M_total); \
NFFT_EXTERN void X(init_m)(X(plan) *ths_plan, int d, int *N, int M_total, int m);\
NFFT_EXTERN void X(init_guru)(X(plan) *ths_plan, int d, int *N, int M_total, int *n, \
  int m, unsigned nfst_flags, unsigned fftw_flags); \
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan); \
NFFT_EXTERN void X(full_psi)(X(plan) *ths_plan, R eps); \
NFFT_EXTERN R X(phi_hut)(X(plan) *ths_plan, int k, int d); \
NFFT_EXTERN R X(phi)(X(plan) *ths_plan, R x, int d); \
NFFT_EXTERN int X(fftw_2N)(int n); \
NFFT_EXTERN int X(fftw_2N_rev)(int n);

#ifdef HAVE_NFST
/* nfst api */
NFST_DEFINE_API(NFST_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,float,fftwf_complex)
NFST_DEFINE_API(NFST_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,double,fftw_complex)
NFST_DEFINE_API(NFST_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* nnfft */

/* name mangling macros */
#define NNFFT_MANGLE_DOUBLE(name) NFFT_CONCAT(nnfft_, name)
#define NNFFT_MANGLE_FLOAT(name) NFFT_CONCAT(nnfftf_, name)
#define NNFFT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nnfftl_, name)

/* huge second-order macro that defines prototypes for all nfst API functions.
 * We expand this macro for each supported precision.
 *   X: nnfft name-mangling macro
 *   Y: fftw name-mangling macro
 *   Z: nfft name mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NNFFT_DEFINE_API(X,Y,Z,R,C) \
typedef struct\
{\
  /* api */\
  MACRO_MV_PLAN(C)\
\
  int d; /**< dimension, rank */\
  R *sigma; /**< oversampling-factor */\
  R *a; /**< 1 + 2*m/N1 */\
  int *N; /**< cut-off-frequencies */\
  int *N1; /**< sigma*N */\
  int *aN1; /**< sigma*a*N */\
  int m; /**< cut-off parameter in time-domain*/\
  R *b; /**< shape parameters */\
  int K; /**< number of precomp. uniform psi */\
  int aN1_total; /**< aN1_total=aN1[0]* ... *aN1[d-1] */\
  Z(plan) *direct_plan; /**< plan for the nfft */\
  unsigned nnfft_flags; /**< flags for precomputation, malloc*/\
  int *n; /**< n=N1, for the window function */\
  R *x; /**< nodes (in time/spatial domain) */\
  R *v; /**< nodes (in fourier domain) */\
  R *c_phi_inv; /**< precomputed data, matrix D */\
  R *psi; /**< precomputed data, matrix B */\
  int size_psi; /**< only for thin B */\
  int *psi_index_g; /**< only for thin B */\
  int *psi_index_f; /**< only for thin B */\
  C *F;\
  R *spline_coeffs; /**< input for de Boor algorithm, if B_SPLINE or SINC_2m is defined */\
} X(plan);\
\
NFFT_EXTERN void X(init)(X(plan) *ths_plan, int d, int N_total, int M_total, int *N); \
NFFT_EXTERN void X(init_guru)(X(plan) *ths_plan, int d, int N_total, int M_total, \
  int *N, int *N1, int m, unsigned nnfft_flags); \
NFFT_EXTERN void X(trafo_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint_direct)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths_plan); \
NFFT_EXTERN void X(precompute_lin_psi)(X(plan) *ths_plan); \
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths_plan); \
NFFT_EXTERN void X(precompute_full_psi)(X(plan) *ths_plan); \
NFFT_EXTERN void X(precompute_phi_hut)(X(plan) *ths_plan); \
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan);

#ifdef HAVE_NNFFT
/* nnfft api */
NNFFT_DEFINE_API(NNFFT_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,float,fftwf_complex)
NNFFT_DEFINE_API(NNFFT_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,double,fftw_complex)
NNFFT_DEFINE_API(NNFFT_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* additional init flags */
#define MALLOC_V         (1U<< 11)

/* nsfft */

#define NSFFT_MANGLE_DOUBLE(name) NFFT_CONCAT(nsfft_, name)
#define NSFFT_MANGLE_FLOAT(name) NFFT_CONCAT(nsfftf_, name)
#define NSFFT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nsfftl_, name)

/* huge second-order macro that defines prototypes for all nnfft API functions.
 * We expand this macro for each supported precision.
 *   X: nnfft name-mangling macro
 *   Y: fftw name-mangling macro
 *   Z: nfft name mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NSFFT_DEFINE_API(X,Y,Z,R,C) \
typedef struct\
{\
  MACRO_MV_PLAN(C)\
\
  int d; /**< dimension, rank; d = 2, 3 */\
  int J; /**< problem size, i.e.,
                d=2: N_total=(J+4) 2^(J+1)
                d=3: N_total=2^J 6(2^((J+1)/2+1)-1)+2^(3(J/2+1)) */\
  int sigma; /**< oversampling-factor */\
  unsigned flags; /**< flags for precomputation, malloc*/\
  int *index_sparse_to_full; /**< index conversation, overflow for d=3, J=9! */\
  int r_act_nfft_plan; /**< index of current nfft block */\
  Z(plan) *act_nfft_plan; /**< current nfft block */\
  Z(plan) *center_nfft_plan; /**< central nfft block */\
  Y(plan) *set_fftw_plan1; /**< fftw plan for the nfft blocks */\
  Y(plan) *set_fftw_plan2; /**< fftw plan for the nfft blocks */\
  Z(plan) *set_nfft_plan_1d; /**< nfft plans for short nffts */\
  Z(plan) *set_nfft_plan_2d; /**< nfft plans for short nffts */\
  R *x_transposed; /**< coordinate exchanged nodes, d = 2 */\
  R *x_102,*x_201,*x_120,*x_021; /**< coordinate exchanged nodes, d=3 */\
} X(plan);\
\
NFFT_EXTERN void X(trafo_direct)(X(plan) *ths); \
NFFT_EXTERN void X(adjoint_direct)(X(plan) *ths); \
NFFT_EXTERN void X(trafo)(X(plan) *ths); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths); \
NFFT_EXTERN void X(cp)(X(plan) *ths, Z(plan) *ths_nfft); \
NFFT_EXTERN void X(init_random_nodes_coeffs)(X(plan) *ths); \
NFFT_EXTERN void X(init)(X(plan) *ths, int d, int J, int M, int m, unsigned flags); \
NFFT_EXTERN void X(finalize)(X(plan) *ths);

#ifdef HAVE_NSFFT
/* nsfft api */
NSFFT_DEFINE_API(NSFFT_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,float,fftwf_complex)
NSFFT_DEFINE_API(NSFFT_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,double,fftw_complex)
NSFFT_DEFINE_API(NSFFT_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* additional init flags */
#define NSDFT            (1U<< 12)

/* mri */

/* name mangling macros */
#define MRI_MANGLE_DOUBLE(name) NFFT_CONCAT(mri_, name)
#define MRI_MANGLE_FLOAT(name) NFFT_CONCAT(mrif_, name)
#define MRI_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(mril_, name)

/* huge second-order macro that defines prototypes for all mri API functions.
 * We expand this macro for each supported precision.
 *   X: mri name-mangling macro
 *   Z: nfft name mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define MRI_DEFINE_API(X,Z,R,C) \
typedef struct\
{\
  MACRO_MV_PLAN(C)\
  Z(plan) plan;\
  int N3;\
  R sigma3;\
  R *t;\
  R *w;\
} X(inh_2d1d_plan);\
\
typedef struct\
{\
  MACRO_MV_PLAN(C)\
  Z(plan) plan;\
  int N3;\
  R sigma3;\
  R *t;\
  R *w;\
} X(inh_3d_plan);\
\
void X(inh_2d1d_trafo)(X(inh_2d1d_plan) *ths); \
void X(inh_2d1d_adjoint)(X(inh_2d1d_plan) *ths); \
void X(inh_2d1d_init_guru)(X(inh_2d1d_plan) *ths, int *N, int M, int *n, \
  int m, R sigma, unsigned nfft_flags, unsigned fftw_flags); \
void X(inh_2d1d_finalize)(X(inh_2d1d_plan) *ths); \
void X(inh_3d_trafo)(X(inh_3d_plan) *ths); \
void X(inh_3d_adjoint)(X(inh_3d_plan) *ths); \
void X(inh_3d_init_guru)(X(inh_3d_plan) *ths, int *N, int M, int *n, \
  int m, R sigma, unsigned nfft_flags, unsigned fftw_flags); \
void X(inh_3d_finalize)(X(inh_3d_plan) *ths);

#ifdef HAVE_MRI
  /* mri api */
MRI_DEFINE_API(MRI_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,float,fftwf_complex)
MRI_DEFINE_API(MRI_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,double,fftw_complex)
MRI_DEFINE_API(MRI_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* nfsft */

/* name mangling macros */
#define NFSFT_MANGLE_DOUBLE(name) NFFT_CONCAT(nfsft_, name)
#define NFSFT_MANGLE_FLOAT(name) NFFT_CONCAT(nfsftf_, name)
#define NFSFT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nfsftl_, name)

/* huge second-order macro that defines prototypes for all nfsft API functions.
 * We expand this macro for each supported precision.
 *   X: nfsft name-mangling macro
 *   Z: nfft name mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NFSFT_DEFINE_API(X,Z,R,C) \
typedef struct\
{\
  MACRO_MV_PLAN(C)\
  int N; /**< the bandwidth \f$N\f$ */\
  R *x; /**< the nodes \f$\mathbf{x}(m) = \left(x_1,x_2\right) \in
    [-\frac{1}{2},\frac{1}{2}) \times [0,\frac{1}{2}]\f$ for \f$m=0,\ldots,
    M-1\f$,\f$M \in \mathbb{N},\f$ */\
  /* internal use only */\
  int t; /**< the logarithm of NPT with respect to the basis 2 */\
  unsigned int flags; /**< the planner flags */\
  Z(plan) plan_nfft; /**< the internal NFFT plan */\
  C *f_hat_intern; /**< Internally used pointer to spherical Fourier
    coefficients */\
  double MEASURE_TIME_t[3]; /**< Measured time for each step if MEASURE_TIME is
    set */\
} X(plan);\
\
NFFT_EXTERN void X(init)(X(plan) *plan, int N, int M); \
NFFT_EXTERN void X(init_advanced)(X(plan)* plan, int N, int M, unsigned int \
  nfsft_flags); \
NFFT_EXTERN void X(init_guru)(X(plan) *plan, int N, int M, \
  unsigned int nfsft_flags, unsigned int nfft_flags, int nfft_cutoff); \
NFFT_EXTERN void X(precompute)(int N, R kappa, unsigned int nfsft_flags, \
  unsigned int fpt_flags); \
NFFT_EXTERN void X(forget)(void); \
NFFT_EXTERN void X(trafo_direct)(X(plan)* plan); \
NFFT_EXTERN void X(adjoint_direct)(X(plan)* plan); \
NFFT_EXTERN void X(trafo)(X(plan)* plan); \
NFFT_EXTERN void X(adjoint)(X(plan)* plan); \
NFFT_EXTERN void X(finalize)(X(plan) *plan); \
NFFT_EXTERN void X(precompute_x)(X(plan) *plan);

#ifdef HAVE_NFSFT
/* nfsft api */
NFSFT_DEFINE_API(NFSFT_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,float,fftwf_complex)
NFSFT_DEFINE_API(NFSFT_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,double,fftw_complex)
NFSFT_DEFINE_API(NFSFT_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#endif

/* init flags */
#define NFSFT_NORMALIZED     (1U << 0)
#define NFSFT_USE_NDFT       (1U << 1)
#define NFSFT_USE_DPT        (1U << 2)
#define NFSFT_MALLOC_X       (1U << 3)
#define NFSFT_MALLOC_F_HAT   (1U << 5)
#define NFSFT_MALLOC_F       (1U << 6)
#define NFSFT_PRESERVE_F_HAT (1U << 7)
#define NFSFT_PRESERVE_X     (1U << 8)
#define NFSFT_PRESERVE_F     (1U << 9)
#define NFSFT_DESTROY_F_HAT  (1U << 10)
#define NFSFT_DESTROY_X      (1U << 11)
#define NFSFT_DESTROY_F      (1U << 12)

/* precompute flags */
#define NFSFT_NO_DIRECT_ALGORITHM (1U << 13)
#define NFSFT_NO_FAST_ALGORITHM   (1U << 14)
#define NFSFT_ZERO_F_HAT          (1U << 16)

/* helper macros */
#define NFSFT_INDEX(k,n,plan) ((2*(plan)->N+2)*((plan)->N-n+1)+(plan)->N+k+1)
#define NFSFT_F_HAT_SIZE(N) ((2*N+2)*(2*N+2))

/* fpt */

/* name mangling macros */
#define FPT_MANGLE_DOUBLE(name) NFFT_CONCAT(fpt_, name)
#define FPT_MANGLE_FLOAT(name) NFFT_CONCAT(fptf_, name)
#define FPT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(fptl_, name)

/* huge second-order macro that defines prototypes for all fpt API functions.
 * We expand this macro for each supported precision.
 *   X: fpt name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define FPT_DEFINE_API(X,Y,R,C) \
typedef struct X(set_s_) *X(set); /**< A set of precomputed data for a set of
  DPT transforms of equal maximum length. */\
\
NFFT_EXTERN X(set) X(init)(const int M, const int t, const unsigned int flags); \
NFFT_EXTERN void X(precompute)(X(set) set, const int m, R *alpha, R *beta, \
  R *gam, int k_start, const R threshold); \
NFFT_EXTERN void X(trafo_direct)(X(set) set, const int m, const C *x, C *y, \
  const int k_end, const unsigned int flags); \
NFFT_EXTERN void X(trafo)(X(set) set, const int m, const C *x, C *y, \
  const int k_end, const unsigned int flags); \
NFFT_EXTERN void X(transposed_direct)(X(set) set, const int m, C *x, \
  C *y, const int k_end, const unsigned int flags); \
NFFT_EXTERN void X(transposed)(X(set) set, const int m, C *x, \
  C *y, const int k_end, const unsigned int flags); \
NFFT_EXTERN void X(finalize)(X(set) set);

#ifdef HAVE_FPT
/* fpt api */
FPT_DEFINE_API(FPT_MANGLE_FLOAT,FFTW_MANGLE_FLOAT,float,fftwf_complex)
FPT_DEFINE_API(FPT_MANGLE_DOUBLE,FFTW_MANGLE_DOUBLE,double,fftw_complex)
FPT_DEFINE_API(FPT_MANGLE_LONG_DOUBLE,FFTW_MANGLE_LONG_DOUBLE,long double,fftwl_complex)

/* init flags */
#define FPT_NO_STABILIZATION    (1U << 0)
#define FPT_NO_FAST_ALGORITHM   (1U << 2)
#define FPT_NO_DIRECT_ALGORITHM (1U << 3)
#define FPT_PERSISTENT_DATA     (1U << 4)

/* transform flags */
#define FPT_FUNCTION_VALUES     (1U << 5)
#define FPT_AL_SYMMETRY         (1U << 6)
#endif

/* nfsoft*/

/* name mangling macros */
#define NFSOFT_MANGLE_DOUBLE(name) NFFT_CONCAT(nfsoft_, name)
#define NFSOFT_MANGLE_FLOAT(name) NFFT_CONCAT(nfsoftf_, name)
#define NFSOFT_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(nfsoftl_, name)

/* huge second-order macro that defines prototypes for all nfsoft API functions.
 * We expand this macro for each supported precision.
 *   X: nfsoft name-mangling macro
 *   Y: nfft name-mangling macro
 *   Z: fpt name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define NFSOFT_DEFINE_API(X,Y,Z,R,C) \
typedef struct X(plan_)\
{\
  MACRO_MV_PLAN(C) \
  R *x; /**< input nodes */\
  C *wig_coeffs; /**< contains a set of SO(3) Fourier coefficients for fixed
    orders m and n*/\
  C *cheby; /**< contains a set of Chebychev coefficients for fixed orders m
    and n*/\
  C *aux; /**< used when converting Chebychev to Fourier coeffcients*/\
  /* internal use only */\
  int t; /**< the logaritm of NPT with respect to the basis 2 */\
  unsigned int flags; /**< the planner flags  */\
  Y(plan) p_nfft; /**< the internal NFFT plan */\
  Z(set) internal_fpt_set; /**< the internal FPT plan */\
  int fpt_kappa; /**a parameter controlling the accuracy of the FPT*/\
} X(plan);\
\
NFFT_EXTERN void X(precompute)(X(plan) *plan); \
NFFT_EXTERN Z(set) X(SO3_single_fpt_init)(int l, int k, int m, unsigned int flags, int kappa); \
NFFT_EXTERN void X(SO3_fpt)(C *coeffs, Z(set) set, int l, int k, int m, unsigned int nfsoft_flags); \
NFFT_EXTERN void X(SO3_fpt_transposed)(C *coeffs, Z(set) set,int l, int k, int m,unsigned int nfsoft_flags); \
NFFT_EXTERN void X(init)(X(plan) *plan, int N, int M); \
NFFT_EXTERN void X(init_advanced)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags); \
NFFT_EXTERN void X(init_guru)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags,unsigned int nfft_flags,int nfft_cutoff,int fpt_kappa); \
NFFT_EXTERN void X(trafo)(X(plan) *plan_nfsoft); \
NFFT_EXTERN void X(adjoint)(X(plan) *plan_nfsoft); \
NFFT_EXTERN void X(finalize)(X(plan) *plan); \
NFFT_EXTERN int X(posN)(int n,int m, int B);

#ifdef HAVE_NFSOFT
/* nfsoft api */
NFSOFT_DEFINE_API(NFSOFT_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,FPT_MANGLE_FLOAT,float,fftwf_complex)
NFSOFT_DEFINE_API(NFSOFT_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,FPT_MANGLE_DOUBLE,double,fftw_complex)
NFSOFT_DEFINE_API(NFSOFT_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,FPT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)

/* init flags */
#define NFSOFT_NORMALIZED     (1U << 0)
#define NFSOFT_USE_NDFT       (1U << 1)
#define NFSOFT_USE_DPT        (1U << 2)
#define NFSOFT_MALLOC_X       (1U << 3)
#define NFSOFT_REPRESENT      (1U << 4)
#define NFSOFT_MALLOC_F_HAT   (1U << 5)
#define NFSOFT_MALLOC_F       (1U << 6)
#define NFSOFT_PRESERVE_F_HAT (1U << 7)
#define NFSOFT_PRESERVE_X     (1U << 8)
#define NFSOFT_PRESERVE_F     (1U << 9)
#define NFSOFT_DESTROY_F_HAT  (1U << 10)
#define NFSOFT_DESTROY_X      (1U << 11)
#define NFSOFT_DESTROY_F      (1U << 12)

/* precompute flags */
#define NFSOFT_NO_STABILIZATION (1U << 13)
#define NFSOFT_CHOOSE_DPT       (1U << 14)
#define NFSOFT_SOFT             (1U << 15)
#define NFSOFT_ZERO_F_HAT       (1U << 16)

/* helper macros */
#define NFSOFT_INDEX(m,n,l,B) (((l)+((B)+1))+(2*(B)+2)*(((n)+((B)+1))+(2*(B)+2)*((m)+((B)+1))))
#define NFSOFT_INDEX_TWO(m,n,l,B) ((B+1)*(B+1)+(B+1)*(B+1)*(m+B)-((m-1)*m*(2*m-1)+(B+1)*(B+2)*(2*B+3))/6)+(posN(n,m,B))+(l-MAX(ABS(m),ABS(n)))
#define NFSOFT_F_HAT_SIZE(B) (((B)+1)*(4*((B)+1)*((B)+1)-1)/3)

#endif

/*solver */

/* name mangling macros */
#define SOLVER_MANGLE_DOUBLE(name) NFFT_CONCAT(solver_, name)
#define SOLVER_MANGLE_FLOAT(name) NFFT_CONCAT(solverf_, name)
#define SOLVER_MANGLE_LONG_DOUBLE(name) NFFT_CONCAT(solverl_, name)

/* huge second-order macro that defines prototypes for all nfsoft API functions.
 * We expand this macro for each supported precision.
 *   X: nfsoft name-mangling macro
 *   Y: nfft name-mangling macro
 *   R: real data type
 *   C: complex data type
 */
#define SOLVER_DEFINE_API(X,Y,R,C)\
typedef struct\
{\
  Y(mv_plan_complex) *mv; /**< matrix vector multiplication   */\
  unsigned flags; /**< iteration type */\
  R *w; /**< weighting factors */\
  R *w_hat; /**< damping factors */\
  C *y; /**< right hand side, samples */\
  C *f_hat_iter; /**< iterative solution */\
  C *r_iter; /**< iterated residual vector */\
  C *z_hat_iter; /**< residual of normal equation of first kind */\
  C *p_hat_iter; /**< search direction */\
  C *v_iter; /**< residual vector update */\
  R alpha_iter; /**< step size for search direction */\
  R beta_iter; /**< step size for search correction*/\
  R dot_r_iter; /**< weighted dotproduct of r_iter */\
  R dot_r_iter_old; /**< previous dot_r_iter */\
  R dot_z_hat_iter; /**< weighted dotproduct of z_hat_iter */\
  R dot_z_hat_iter_old; /**< previous dot_z_hat_iter */\
  R dot_p_hat_iter; /**< weighted dotproduct of p_hat_iter */\
  R dot_v_iter; /**< weighted dotproduct of v_iter */\
} X(plan_complex);\
\
NFFT_EXTERN void X(init_advanced_complex)(X(plan_complex)* ths, Y(mv_plan_complex) *mv, unsigned flags);\
NFFT_EXTERN void X(init_complex)(X(plan_complex)* ths, Y(mv_plan_complex) *mv);\
NFFT_EXTERN void X(before_loop_complex)(X(plan_complex)* ths);\
NFFT_EXTERN void X(loop_one_step_complex)(X(plan_complex) *ths);\
NFFT_EXTERN void X(finalize_complex)(X(plan_complex) *ths);\
\
typedef struct\
{\
  Y(mv_plan_double) *mv; /**< matrix vector multiplication   */\
  unsigned flags; /**< iteration type */\
  R *w; /**< weighting factors */\
  R *w_hat; /**< damping factors */\
  R *y; /**< right hand side, samples */\
  R *f_hat_iter; /**< iterative solution */\
  R *r_iter; /**< iterated residual vector */\
  R *z_hat_iter; /**< residual of normal equation of first kind */\
  R *p_hat_iter; /**< search direction */\
  R *v_iter; /**< residual vector update */\
  R alpha_iter; /**< step size for search direction */\
  R beta_iter; /**< step size for search correction */\
  R dot_r_iter; /**< weighted dotproduct of r_iter */\
  R dot_r_iter_old; /**< previous dot_r_iter */\
  R dot_z_hat_iter; /**< weighted dotproduct of z_hat_iter */\
  R dot_z_hat_iter_old; /**< previous dot_z_hat_iter */\
  R dot_p_hat_iter; /**< weighted dotproduct of p_hat_iter */\
  R dot_v_iter; /**< weighted dotproduct of v_iter */\
} X(plan_double);\
\
NFFT_EXTERN void X(init_advanced_double)(X(plan_double)* ths, Y(mv_plan_double) *mv, unsigned flags);\
NFFT_EXTERN void X(solver_init_double)(X(plan_double)* ths, Y(mv_plan_double) *mv);\
NFFT_EXTERN void X(solver_before_loop_double)(X(plan_double)* ths);\
NFFT_EXTERN void X(solver_loop_one_step_double)(X(plan_double) *ths);\
NFFT_EXTERN void X(solver_finalize_double)(X(plan_double) *ths);

/* solver api */
SOLVER_DEFINE_API(SOLVER_MANGLE_FLOAT,NFFT_MANGLE_FLOAT,float,fftwf_complex)
SOLVER_DEFINE_API(SOLVER_MANGLE_DOUBLE,NFFT_MANGLE_DOUBLE,double,fftw_complex)
SOLVER_DEFINE_API(SOLVER_MANGLE_LONG_DOUBLE,NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)

/* init flags */
#define LANDWEBER             (1U<< 0)
#define STEEPEST_DESCENT      (1U<< 1)
#define CGNR                  (1U<< 2)
#define CGNE                  (1U<< 3)
#define NORMS_FOR_LANDWEBER   (1U<< 4)
#define PRECOMPUTE_WEIGHT     (1U<< 5)
#define PRECOMPUTE_DAMP       (1U<< 6)

#ifdef __cplusplus
}  /* extern "C" */
#endif /* __cplusplus */

#endif /* defined(__NFFT3_H__) */