00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FFTW_H
00025 #define FFTW_H
00026
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034
00035
00036
00037
00038
00039 #define FFTW_ENABLE_FLOAT 1
00040
00041
00042 #ifdef FFTW_ENABLE_FLOAT
00043 typedef float fftw_real;
00044 #else
00045 typedef double fftw_real;
00046 #endif
00047
00048
00049
00050
00051 typedef struct {
00052 fftw_real re, im;
00053 } fftw_complex;
00054
00055 #define c_re(c) ((c).re)
00056 #define c_im(c) ((c).im)
00057
00058 typedef enum {
00059 FFTW_FORWARD = -1, FFTW_BACKWARD = 1
00060 } fftw_direction;
00061
00062
00063 typedef fftw_complex FFTW_COMPLEX;
00064 typedef fftw_real FFTW_REAL;
00065
00066 #ifndef FFTW_1_0_COMPATIBILITY
00067 #define FFTW_1_0_COMPATIBILITY 0
00068 #endif
00069
00070 #if FFTW_1_0_COMPATIBILITY
00071
00072 #define REAL fftw_real
00073 #define COMPLEX fftw_complex
00074 #endif
00075
00076
00077
00078
00079
00080 typedef enum {
00081 FFTW_SUCCESS = 0, FFTW_FAILURE = -1
00082 } fftw_status;
00083
00084
00085
00086
00087 typedef void (fftw_notw_codelet)
00088 (const fftw_complex *, fftw_complex *, int, int);
00089 typedef void (fftw_twiddle_codelet)
00090 (fftw_complex *, const fftw_complex *, int,
00091 int, int);
00092 typedef void (fftw_generic_codelet)
00093 (fftw_complex *, const fftw_complex *, int,
00094 int, int, int);
00095 typedef void (fftw_real2hc_codelet)
00096 (const fftw_real *, fftw_real *, fftw_real *,
00097 int, int, int);
00098 typedef void (fftw_hc2real_codelet)
00099 (const fftw_real *, const fftw_real *,
00100 fftw_real *, int, int, int);
00101 typedef void (fftw_hc2hc_codelet)
00102 (fftw_real *, const fftw_complex *,
00103 int, int, int);
00104 typedef void (fftw_rgeneric_codelet)
00105 (fftw_real *, const fftw_complex *, int,
00106 int, int, int);
00107
00108
00109
00110
00111
00112
00113
00114
00115 enum fftw_node_type {
00116 FFTW_NOTW, FFTW_TWIDDLE, FFTW_GENERIC, FFTW_RADER,
00117 FFTW_REAL2HC, FFTW_HC2REAL, FFTW_HC2HC, FFTW_RGENERIC
00118 };
00119
00120
00121 typedef struct {
00122 const char *name;
00123 void (*codelet) ();
00124 int size;
00125 fftw_direction dir;
00126 enum fftw_node_type type;
00127 int signature;
00128 int ntwiddle;
00129 const int *twiddle_order;
00130
00131
00132
00133
00134 } fftw_codelet_desc;
00135
00136
00137
00138 #ifdef HAVE_WIN32
00139 # if defined(BUILD_FFTW_DLL)
00140 # define DL_IMPORT(type) __declspec(dllexport) type
00141 # elif defined(USE_FFTW_DLL)
00142 # define DL_IMPORT(type) __declspec(dllimport) type
00143 # else
00144 # define DL_IMPORT(type) type
00145 # endif
00146 #else
00147 # define DL_IMPORT(type) type
00148 #endif
00149
00150 extern DL_IMPORT(const char *) fftw_version;
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 typedef struct fftw_twiddle_struct {
00166 int n;
00167 const fftw_codelet_desc *cdesc;
00168 fftw_complex *twarray;
00169 struct fftw_twiddle_struct *next;
00170 int refcnt;
00171 } fftw_twiddle;
00172
00173 typedef struct fftw_rader_data_struct {
00174 struct fftw_plan_struct *plan;
00175 fftw_complex *omega;
00176 int g, ginv;
00177 int p, flags, refcount;
00178 struct fftw_rader_data_struct *next;
00179 fftw_codelet_desc *cdesc;
00180 } fftw_rader_data;
00181
00182 typedef void (fftw_rader_codelet)
00183 (fftw_complex *, const fftw_complex *, int,
00184 int, int, fftw_rader_data *);
00185
00186
00187 typedef struct fftw_plan_node_struct {
00188 enum fftw_node_type type;
00189
00190 union {
00191
00192 struct {
00193 int size;
00194 fftw_notw_codelet *codelet;
00195 const fftw_codelet_desc *codelet_desc;
00196 } notw;
00197
00198
00199 struct {
00200 int size;
00201 fftw_twiddle_codelet *codelet;
00202 fftw_twiddle *tw;
00203 struct fftw_plan_node_struct *recurse;
00204 const fftw_codelet_desc *codelet_desc;
00205 } twiddle;
00206
00207
00208 struct {
00209 int size;
00210 fftw_generic_codelet *codelet;
00211 fftw_twiddle *tw;
00212 struct fftw_plan_node_struct *recurse;
00213 } generic;
00214
00215
00216 struct {
00217 int size;
00218 fftw_rader_codelet *codelet;
00219 fftw_rader_data *rader_data;
00220 fftw_twiddle *tw;
00221 struct fftw_plan_node_struct *recurse;
00222 } rader;
00223
00224
00225 struct {
00226 int size;
00227 fftw_real2hc_codelet *codelet;
00228 const fftw_codelet_desc *codelet_desc;
00229 } real2hc;
00230
00231
00232 struct {
00233 int size;
00234 fftw_hc2real_codelet *codelet;
00235 const fftw_codelet_desc *codelet_desc;
00236 } hc2real;
00237
00238
00239 struct {
00240 int size;
00241 fftw_direction dir;
00242 fftw_hc2hc_codelet *codelet;
00243 fftw_twiddle *tw;
00244 struct fftw_plan_node_struct *recurse;
00245 const fftw_codelet_desc *codelet_desc;
00246 } hc2hc;
00247
00248
00249 struct {
00250 int size;
00251 fftw_direction dir;
00252 fftw_rgeneric_codelet *codelet;
00253 fftw_twiddle *tw;
00254 struct fftw_plan_node_struct *recurse;
00255 } rgeneric;
00256 } nodeu;
00257
00258 int refcnt;
00259 } fftw_plan_node;
00260
00261 typedef enum {
00262 FFTW_NORMAL_RECURSE = 0,
00263 FFTW_VECTOR_RECURSE = 1
00264 } fftw_recurse_kind;
00265
00266 struct fftw_plan_struct {
00267 int n;
00268 int refcnt;
00269 fftw_direction dir;
00270 int flags;
00271 int wisdom_signature;
00272 enum fftw_node_type wisdom_type;
00273 struct fftw_plan_struct *next;
00274 fftw_plan_node *root;
00275 double cost;
00276 fftw_recurse_kind recurse_kind;
00277 int vector_size;
00278 };
00279
00280 typedef struct fftw_plan_struct *fftw_plan;
00281
00282
00283 #define FFTW_ESTIMATE (0)
00284 #define FFTW_MEASURE (1)
00285
00286 #define FFTW_OUT_OF_PLACE (0)
00287 #define FFTW_IN_PLACE (8)
00288 #define FFTW_USE_WISDOM (16)
00289
00290 #define FFTW_THREADSAFE (128)
00291
00292
00293
00294 #define FFTWND_FORCE_BUFFERED (256)
00295
00296
00297 #define FFTW_NO_VECTOR_RECURSE (512)
00298
00299
00300 extern fftw_plan fftw_create_plan_specific(int n, fftw_direction dir,
00301 int flags,
00302 fftw_complex *in, int istride,
00303 fftw_complex *out, int ostride);
00304 #define FFTW_HAS_PLAN_SPECIFIC
00305 extern fftw_plan fftw_create_plan(int n, fftw_direction dir, int flags);
00306 extern void fftw_print_plan(fftw_plan plan);
00307 extern void fftw_destroy_plan(fftw_plan plan);
00308 extern void fftw(fftw_plan plan, int howmany, fftw_complex *in, int istride,
00309 int idist, fftw_complex *out, int ostride, int odist);
00310 extern void fftw_one(fftw_plan plan, fftw_complex *in, fftw_complex *out);
00311
00312
00313
00314 #if 0
00315 extern void fftw_die(const char *s);
00316 extern void *fftw_malloc(size_t n);
00317 extern void fftw_free(void *p);
00318 extern void fftw_check_memory_leaks(void);
00319 extern void fftw_print_max_memory_usage(void);
00320 #else
00321 # ifndef RWCOX
00322 # define fftw_malloc malloc
00323 # define fftw_free free
00324 # define fftw_die(s) (fflush(stdout),fprintf(stderr,"fftw: %s\n",s),exit(1))
00325 # define fftw_check_memory_leaks
00326 # define fftw_print_max_memory_usage
00327 # endif
00328 #endif
00329
00330 typedef void *(*fftw_malloc_type_function) (size_t n);
00331 typedef void (*fftw_free_type_function) (void *p);
00332 typedef void (*fftw_die_type_function) (const char *errString);
00333 extern DL_IMPORT(fftw_malloc_type_function) fftw_malloc_hook;
00334 extern DL_IMPORT(fftw_free_type_function) fftw_free_hook;
00335 extern DL_IMPORT(fftw_die_type_function) fftw_die_hook;
00336
00337 extern size_t fftw_sizeof_fftw_real(void);
00338
00339
00340
00341
00342
00343
00344 #define FFTW_HAS_WISDOM
00345 extern void fftw_forget_wisdom(void);
00346 extern void fftw_export_wisdom(void (*emitter) (char c, void *), void *data);
00347 extern fftw_status fftw_import_wisdom(int (*g) (void *), void *data);
00348 extern void fftw_export_wisdom_to_file(FILE *output_file);
00349 extern fftw_status fftw_import_wisdom_from_file(FILE *input_file);
00350 extern char *fftw_export_wisdom_to_string(void);
00351 extern fftw_status fftw_import_wisdom_from_string(const char *input_string);
00352
00353
00354
00355
00356
00357 #define FFTW_HAS_FPRINT_PLAN
00358 extern void fftw_fprint_plan(FILE *f, fftw_plan plan);
00359
00360
00361
00362
00363 typedef struct {
00364 int is_in_place;
00365
00366 int rank;
00367
00368
00369
00370 int *n;
00371
00372
00373
00374 fftw_direction dir;
00375
00376 int *n_before;
00377
00378
00379 int *n_after;
00380
00381 fftw_plan *plans;
00382
00383 int nbuffers, nwork;
00384 fftw_complex *work;
00385
00386
00387
00388
00389 } fftwnd_data;
00390
00391 typedef fftwnd_data *fftwnd_plan;
00392
00393
00394 extern fftwnd_plan fftw2d_create_plan(int nx, int ny, fftw_direction dir,
00395 int flags);
00396 extern fftwnd_plan fftw3d_create_plan(int nx, int ny, int nz,
00397 fftw_direction dir, int flags);
00398 extern fftwnd_plan fftwnd_create_plan(int rank, const int *n,
00399 fftw_direction dir,
00400 int flags);
00401
00402 extern fftwnd_plan fftw2d_create_plan_specific(int nx, int ny,
00403 fftw_direction dir,
00404 int flags,
00405 fftw_complex *in, int istride,
00406 fftw_complex *out, int ostride);
00407 extern fftwnd_plan fftw3d_create_plan_specific(int nx, int ny, int nz,
00408 fftw_direction dir, int flags,
00409 fftw_complex *in, int istride,
00410 fftw_complex *out, int ostride);
00411 extern fftwnd_plan fftwnd_create_plan_specific(int rank, const int *n,
00412 fftw_direction dir,
00413 int flags,
00414 fftw_complex *in, int istride,
00415 fftw_complex *out, int ostride);
00416
00417
00418 extern void fftwnd_destroy_plan(fftwnd_plan plan);
00419
00420
00421 extern void fftwnd_fprint_plan(FILE *f, fftwnd_plan p);
00422 extern void fftwnd_print_plan(fftwnd_plan p);
00423 #define FFTWND_HAS_PRINT_PLAN
00424
00425
00426 extern void fftwnd(fftwnd_plan plan, int howmany,
00427 fftw_complex *in, int istride, int idist,
00428 fftw_complex *out, int ostride, int odist);
00429 extern void fftwnd_one(fftwnd_plan p, fftw_complex *in, fftw_complex *out);
00430
00431 #ifdef __cplusplus
00432 }
00433
00434 #endif
00435 #endif