nfft3.h
Go to the documentation of this file.
/*
* Copyright (c) 2002, 2017 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.
*/
#ifndef __NFFT3_H__
#define __NFFT3_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 NFFT_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
/* Integral type large enough to contain a stride (what ``int'' should have been
* in the first place) */
typedef ptrdiff_t NFFT_INT;
/* Members inherited by all plans. */
#define MACRO_MV_PLAN(RC) \
NFFT_INT N_total; \
NFFT_INT M_total; \
RC *f_hat; \
RC *f; \
void (*mv_trafo)(void*); \
void (*mv_adjoint)(void*);
/* 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)
#define NFFT_DEFINE_MALLOC_API(X) \
/* our own memory allocation and exit functions */ \
NFFT_EXTERN void *X(malloc)(size_t n); \
NFFT_EXTERN void X(free)(void *p); \
NFFT_EXTERN void X(die)(const char *s); \
\
/* You can replace the hooks with your own functions, if necessary. We */ \
/* need this for the Matlab interface. */ \
typedef void *(*X(malloc_type_function)) (size_t n); \
typedef void (*X(free_type_function)) (void *p); \
typedef void (*X(die_type_function)) (const char *errString); \
NFFT_EXTERN X(malloc_type_function) X(malloc_hook); \
NFFT_EXTERN X(free_type_function) X(free_hook); \
NFFT_EXTERN X(die_type_function) X(die_hook);
/* Nfft module API. */
NFFT_DEFINE_MALLOC_API(NFFT_MANGLE_FLOAT)
NFFT_DEFINE_MALLOC_API(NFFT_MANGLE_DOUBLE)
NFFT_DEFINE_MALLOC_API(NFFT_MANGLE_LONG_DOUBLE)
/* Macro to define 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 float type
* C: Complex float 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)\
\
NFFT_INT d; \
NFFT_INT *N; \
R *sigma; \
NFFT_INT *n; \
NFFT_INT n_total; \
NFFT_INT m; \
R *b; \
NFFT_INT K; \
\
unsigned flags; \
\
unsigned fftw_flags; \
\
R *x; \
\
R MEASURE_TIME_t[3]; \
\
/* internal use only */\
Y(plan) my_fftw_plan1; \
Y(plan) my_fftw_plan2; \
\
R **c_phi_inv; \
R *psi; \
NFFT_INT *psi_index_g; \
NFFT_INT *psi_index_f; \
\
C *g; \
C *g_hat; \
C *g1; \
C *g2; \
\
R *spline_coeffs; \
\
NFFT_INT *index_x; \
} X(plan); \
\
NFFT_EXTERN void X(trafo_direct)(const X(plan) *ths);\
NFFT_EXTERN void X(adjoint_direct)(const 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 flags, unsigned fftw_flags);\
NFFT_EXTERN void X(init_lin)(X(plan) *ths, int d, int *N, int M, int *n, \
int m, int K, unsigned flags, unsigned fftw_flags); \
NFFT_EXTERN void X(precompute_one_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_full_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_fg_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 module 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 routines. */
#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)\
\
NFFT_INT d; \
NFFT_INT *N; \
NFFT_INT *n; \
NFFT_INT n_total; \
R *sigma; \
NFFT_INT m; \
\
R *b; \
NFFT_INT K; \
\
unsigned flags; \
unsigned fftw_flags; \
\
R *x; \
\
double MEASURE_TIME_t[3]; \
\
/* internal use only */\
Y(plan) my_fftw_r2r_plan; \
Y(r2r_kind) *r2r_kind; \
\
R **c_phi_inv; \
R *psi; \
NFFT_INT size_psi; \
NFFT_INT *psi_index_g; \
NFFT_INT *psi_index_f; \
\
R *g;\
R *g_hat;\
R *g1; \
R *g2; \
\
R *spline_coeffs; \
} 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 flags, unsigned fftw_flags); \
NFFT_EXTERN void X(precompute_one_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_full_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_fg_psi)(X(plan) *ths); \
NFFT_EXTERN void X(precompute_lin_psi)(X(plan) *ths);\
NFFT_EXTERN void X(trafo)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo_direct)(const X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint_direct)(const X(plan) *ths_plan); \
NFFT_EXTERN const char* X(check)(X(plan) *ths);\
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan); \
/* 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)
/* 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)\
\
NFFT_INT d; \
NFFT_INT *N; \
NFFT_INT *n; \
NFFT_INT n_total; \
R *sigma; \
NFFT_INT m; \
\
R *b; \
NFFT_INT K; \
\
unsigned flags; \
unsigned fftw_flags; \
\
R *x; \
\
double MEASURE_TIME_t[3]; \
\
/* internal use only */\
Y(plan) my_fftw_r2r_plan; \
Y(r2r_kind) *r2r_kind; \
\
R **c_phi_inv; \
R *psi; \
NFFT_INT size_psi; \
NFFT_INT *psi_index_g; \
NFFT_INT *psi_index_f; \
\
R *g;\
R *g_hat;\
R *g1; \
R *g2; \
\
R *spline_coeffs; \
\
R X(full_psi_eps);\
} 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 flags, unsigned fftw_flags); \
NFFT_EXTERN void X(precompute_one_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_full_psi)(X(plan) *ths);\
NFFT_EXTERN void X(precompute_fg_psi)(X(plan) *ths); \
NFFT_EXTERN void X(precompute_lin_psi)(X(plan) *ths);\
NFFT_EXTERN void X(trafo)(X(plan) *ths_plan); \
NFFT_EXTERN void X(trafo_direct)(const X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint)(X(plan) *ths_plan); \
NFFT_EXTERN void X(adjoint_direct)(const X(plan) *ths_plan); \
NFFT_EXTERN const char* X(check)(X(plan) *ths);\
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan); \
/* 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)
/* 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; \
R *sigma; \
R *a; \
int *N; \
int *N1; \
int *aN1; \
int m; \
R *b; \
int K; \
int aN1_total; \
Z(plan) *direct_plan; \
unsigned nnfft_flags; \
int *n; \
R *x; \
R *v; \
R *c_phi_inv; \
R *psi; \
int size_psi; \
int *psi_index_g; \
int *psi_index_f; \
C *F;\
R *spline_coeffs; \
} 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_1d)(X(plan) *ths_plan, int N, int M_total); \
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(precompute_one_psi)(X(plan) *ths);\
NFFT_EXTERN void X(finalize)(X(plan) *ths_plan);
/* 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)
/* 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; \
int J; \
int sigma; \
unsigned flags; \
int *index_sparse_to_full; \
int r_act_nfft_plan; \
Z(plan) *act_nfft_plan; \
Z(plan) *center_nfft_plan; \
Y(plan) *set_fftw_plan1; \
Y(plan) *set_fftw_plan2; \
Z(plan) *set_nfft_plan_1d; \
Z(plan) *set_nfft_plan_2d; \
R *x_transposed; \
R *x_102,*x_201,*x_120,*x_021; \
} 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);
/* 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)
/* 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);
/* 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)
/* 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; \
R *x; \
/* internal use only */\
int t; \
unsigned int flags; \
Z(plan) plan_nfft; \
C *f_hat_intern; \
double MEASURE_TIME_t[3]; \
} 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);
/* 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)
/* 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); \
\
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);
/* 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)
#define FPT_NO_INIT_FPT_DATA (1U << 7)
/* transform flags */
#define FPT_FUNCTION_VALUES (1U << 5)
#define FPT_AL_SYMMETRY (1U << 6)
/* 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; \
/* internal use only */\
C *wig_coeffs; \
C *cheby; \
C *aux; \
int t; \
unsigned int flags; \
Y(plan) p_nfft; \
Z(set) *internal_fpt_set; \
int nthreads; \
} 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(init_guru_advanced)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags,unsigned int nfft_flags,int nfft_cutoff,int fpt_kappa, int nn_oversampled); \
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);
/* 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_F_HAT_SIZE(B) (((B)+1)*(4*((B)+1)*((B)+1)-1)/3)
/* 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; \
unsigned flags; \
R *w; \
R *w_hat; \
C *y; \
C *f_hat_iter; \
C *r_iter; \
C *z_hat_iter; \
C *p_hat_iter; \
C *v_iter; \
R alpha_iter; \
R beta_iter; \
R dot_r_iter; \
R dot_r_iter_old; \
R dot_z_hat_iter; \
R dot_z_hat_iter_old; \
R dot_p_hat_iter; \
R dot_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; \
unsigned flags; \
R *w; \
R *w_hat; \
R *y; \
R *f_hat_iter; \
R *r_iter; \
R *z_hat_iter; \
R *p_hat_iter; \
R *v_iter; \
R alpha_iter; \
R beta_iter; \
R dot_r_iter; \
R dot_r_iter_old; \
R dot_z_hat_iter; \
R dot_z_hat_iter_old; \
R dot_p_hat_iter; \
R dot_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(init_double)(X(plan_double)* ths, Y(mv_plan_double) *mv);\
NFFT_EXTERN void X(before_loop_double)(X(plan_double)* ths);\
NFFT_EXTERN void X(loop_one_step_double)(X(plan_double) *ths);\
NFFT_EXTERN void X(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)
/* util */
/* huge second-order macro that defines prototypes for all utility API functions.
* We expand this macro for each supported precision.
* Y: nfft name-mangling macro
* R: real data type
* C: complex data type
*/
#define NFFT_DEFINE_UTIL_API(Y,R,C) \
/* rand.c */ \
R Y(drand48)(void); \
void Y(srand48)(long int seed); \
\
\
void Y(vrand_unit_complex)(C *x, const NFFT_INT n); \
\
\
void Y(vrand_shifted_unit_double)(R *x, const NFFT_INT n); \
\
void Y(vrand_real)(R *x, const NFFT_INT n, const R a, const R b); \
\
/* print.c */ \
\
void Y(vpr_double)(R *x, const NFFT_INT n, const char *text); \
\
\
void Y(vpr_complex)(C *x, const NFFT_INT n, const char *text); \
/* thread.c */ \
NFFT_INT Y(get_num_threads)(void); \
/* time.c */ \
R Y(clock_gettime_seconds)(void); \
/* error.c: */ \
R Y(error_l_infty_complex)(const C *x, const C *y, const NFFT_INT n); \
R Y(error_l_infty_1_complex)(const C *x, const C *y, const NFFT_INT n, \
const C *z, const NFFT_INT m); \
/* int.c: */ \
NFFT_INT Y(exp2i)(const NFFT_INT a); \
NFFT_INT Y(next_power_of_2)(const NFFT_INT N); \
/* vector1.c */ \
\
R Y(dot_complex)(C *x, NFFT_INT n); \
/* vector3.c */ \
\
void Y(upd_axpy_complex)(C *x, R a, C *y, NFFT_INT n); \
\
void Y(fftshift_complex)(C *x, NFFT_INT d, NFFT_INT* N); \
void Y(fftshift_complex_int)(C *x, int d, int* N); \
\
void Y(get_version)(unsigned *major, unsigned *minor, unsigned *patch); \
\
const char *Y(get_window_name)(); \
NFFT_INT Y(get_default_window_cut_off)();
NFFT_DEFINE_UTIL_API(NFFT_MANGLE_FLOAT,float,fftwf_complex)
NFFT_DEFINE_UTIL_API(NFFT_MANGLE_DOUBLE,double,fftw_complex)
NFFT_DEFINE_UTIL_API(NFFT_MANGLE_LONG_DOUBLE,long double,fftwl_complex)
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* defined(__NFFT3_H__) */