3 * Copyright (c) 1997-1999, 2003 Massachusetts Institute of Technology
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* fftw.h -- system-wide definitions */
32 #endif /* __cplusplus */
34 /* Define for using single precision */
36 * If you can, use configure --enable-float instead of changing this
39 /* #undef FFTW_ENABLE_FLOAT */
41 /* our real numbers */
42 #ifdef FFTW_ENABLE_FLOAT
43 typedef float fftw_real;
45 typedef double fftw_real;
48 /*********************************************
49 * Complex numbers and operations
50 *********************************************/
56 #define c_re(c) ((c).re)
59 #define c_im(c) ((c).im)
63 FFTW_FORWARD = -1, FFTW_BACKWARD = 1
66 /* backward compatibility with FFTW-1.3 */
67 typedef fftw_complex FFTW_COMPLEX;
68 typedef fftw_real FFTW_REAL;
70 #ifndef FFTW_1_0_COMPATIBILITY
71 #define FFTW_1_0_COMPATIBILITY 0
74 #if FFTW_1_0_COMPATIBILITY
75 /* backward compatibility with FFTW-1.0 */
76 #define REAL fftw_real
77 #define COMPLEX fftw_complex
80 /*********************************************
81 * Success or failure status
82 *********************************************/
85 FFTW_SUCCESS = 0, FFTW_FAILURE = -1
88 /*********************************************
90 *********************************************/
91 typedef void (fftw_notw_codelet)
92 (const fftw_complex *, fftw_complex *, int, int);
93 typedef void (fftw_twiddle_codelet)
94 (fftw_complex *, const fftw_complex *, int,
96 typedef void (fftw_generic_codelet)
97 (fftw_complex *, const fftw_complex *, int,
99 typedef void (fftw_real2hc_codelet)
100 (const fftw_real *, fftw_real *, fftw_real *,
102 typedef void (fftw_hc2real_codelet)
103 (const fftw_real *, const fftw_real *,
104 fftw_real *, int, int, int);
105 typedef void (fftw_hc2hc_codelet)
106 (fftw_real *, const fftw_complex *,
108 typedef void (fftw_rgeneric_codelet)
109 (fftw_real *, const fftw_complex *, int,
112 /*********************************************
114 *********************************************/
116 * A configuration is a database of all known codelets
119 enum fftw_node_type {
120 FFTW_NOTW, FFTW_TWIDDLE, FFTW_GENERIC, FFTW_RADER,
121 FFTW_REAL2HC, FFTW_HC2REAL, FFTW_HC2HC, FFTW_RGENERIC
124 /* description of a codelet */
126 const char *name; /* name of the codelet */
127 void (*codelet) (); /* pointer to the codelet itself */
128 int size; /* size of the codelet */
129 fftw_direction dir; /* direction */
130 enum fftw_node_type type; /* TWIDDLE or NO_TWIDDLE */
131 int signature; /* unique id */
132 int ntwiddle; /* number of twiddle factors */
133 const int *twiddle_order; /*
134 * array that determines the order
135 * in which the codelet expects
136 * the twiddle factors
140 /* On Win32, you need to do funny things to access global variables
141 in shared libraries. Thanks to Andrew Sterian for this hack. */
143 # if defined(BUILD_FFTW_DLL)
144 # define DL_IMPORT(type) __declspec(dllexport) type
145 # elif defined(USE_FFTW_DLL)
146 # define DL_IMPORT(type) __declspec(dllimport) type
148 # define DL_IMPORT(type) type
151 # define DL_IMPORT(type) type
154 extern DL_IMPORT(const char *) fftw_version;
156 /*****************************
158 *****************************/
160 * A plan is a sequence of reductions to compute a FFT of
161 * a given size. At each step, the FFT algorithm can:
163 * 1) apply a notw codelet, or
164 * 2) recurse and apply a twiddle codelet, or
165 * 3) apply the generic codelet.
168 /* structure that contains twiddle factors */
169 typedef struct fftw_twiddle_struct {
171 const fftw_codelet_desc *cdesc;
172 fftw_complex *twarray;
173 struct fftw_twiddle_struct *next;
177 typedef struct fftw_rader_data_struct {
178 struct fftw_plan_struct *plan;
181 int p, flags, refcount;
182 struct fftw_rader_data_struct *next;
183 fftw_codelet_desc *cdesc;
186 typedef void (fftw_rader_codelet)
187 (fftw_complex *, const fftw_complex *, int,
188 int, int, fftw_rader_data *);
190 /* structure that holds all the data needed for a given step */
191 typedef struct fftw_plan_node_struct {
192 enum fftw_node_type type;
195 /* nodes of type FFTW_NOTW */
198 fftw_notw_codelet *codelet;
199 const fftw_codelet_desc *codelet_desc;
202 /* nodes of type FFTW_TWIDDLE */
205 fftw_twiddle_codelet *codelet;
207 struct fftw_plan_node_struct *recurse;
208 const fftw_codelet_desc *codelet_desc;
211 /* nodes of type FFTW_GENERIC */
214 fftw_generic_codelet *codelet;
216 struct fftw_plan_node_struct *recurse;
219 /* nodes of type FFTW_RADER */
222 fftw_rader_codelet *codelet;
223 fftw_rader_data *rader_data;
225 struct fftw_plan_node_struct *recurse;
228 /* nodes of type FFTW_REAL2HC */
231 fftw_real2hc_codelet *codelet;
232 const fftw_codelet_desc *codelet_desc;
235 /* nodes of type FFTW_HC2REAL */
238 fftw_hc2real_codelet *codelet;
239 const fftw_codelet_desc *codelet_desc;
242 /* nodes of type FFTW_HC2HC */
246 fftw_hc2hc_codelet *codelet;
248 struct fftw_plan_node_struct *recurse;
249 const fftw_codelet_desc *codelet_desc;
252 /* nodes of type FFTW_RGENERIC */
256 fftw_rgeneric_codelet *codelet;
258 struct fftw_plan_node_struct *recurse;
266 FFTW_NORMAL_RECURSE = 0,
267 FFTW_VECTOR_RECURSE = 1
270 struct fftw_plan_struct {
275 int wisdom_signature;
276 enum fftw_node_type wisdom_type;
277 struct fftw_plan_struct *next;
278 fftw_plan_node *root;
280 fftw_recurse_kind recurse_kind;
284 typedef struct fftw_plan_struct *fftw_plan;
286 /* flags for the planner */
287 #define FFTW_ESTIMATE (0)
288 #define FFTW_MEASURE (1)
290 #define FFTW_OUT_OF_PLACE (0)
291 #define FFTW_IN_PLACE (8)
292 #define FFTW_USE_WISDOM (16)
294 #define FFTW_THREADSAFE (128) /* guarantee plan is read-only so that the
295 same plan can be used in parallel by
298 #define FFTWND_FORCE_BUFFERED (256) /* internal flag, forces buffering
299 in fftwnd transforms */
301 #define FFTW_NO_VECTOR_RECURSE (512) /* internal flag, prevents use
302 of vector recursion */
304 extern fftw_plan fftw_create_plan_specific(int n, fftw_direction dir,
306 fftw_complex *in, int istride,
307 fftw_complex *out, int ostride);
308 #define FFTW_HAS_PLAN_SPECIFIC
309 extern fftw_plan fftw_create_plan(int n, fftw_direction dir, int flags);
310 extern void fftw_print_plan(fftw_plan plan);
311 extern void fftw_destroy_plan(fftw_plan plan);
312 extern void fftw(fftw_plan plan, int howmany, fftw_complex *in, int istride,
313 int idist, fftw_complex *out, int ostride, int odist);
314 extern void fftw_one(fftw_plan plan, fftw_complex *in, fftw_complex *out);
315 extern void fftw_die(const char *s);
316 extern void *fftw_malloc(size_t n);
317 extern void fftw_free(void *p);
318 extern void fftw_check_memory_leaks(void);
319 extern void fftw_print_max_memory_usage(void);
321 typedef void *(*fftw_malloc_type_function) (size_t n);
322 typedef void (*fftw_free_type_function) (void *p);
323 typedef void (*fftw_die_type_function) (const char *errString);
324 extern DL_IMPORT(fftw_malloc_type_function) fftw_malloc_hook;
325 extern DL_IMPORT(fftw_free_type_function) fftw_free_hook;
326 extern DL_IMPORT(fftw_die_type_function) fftw_die_hook;
328 extern size_t fftw_sizeof_fftw_real(void);
332 * define this symbol so that users know we are using a version of FFTW
335 #define FFTW_HAS_WISDOM
336 extern void fftw_forget_wisdom(void);
337 extern void fftw_export_wisdom(void (*emitter) (char c, void *), void *data);
338 extern fftw_status fftw_import_wisdom(int (*g) (void *), void *data);
339 extern void fftw_export_wisdom_to_file(FILE *output_file);
340 extern fftw_status fftw_import_wisdom_from_file(FILE *input_file);
341 extern char *fftw_export_wisdom_to_string(void);
342 extern fftw_status fftw_import_wisdom_from_string(const char *input_string);
345 * define symbol so we know this function is available (it is not in
348 #define FFTW_HAS_FPRINT_PLAN
349 extern void fftw_fprint_plan(FILE *f, fftw_plan plan);
351 /*****************************
353 *****************************/
355 int is_in_place; /* 1 if for in-place FFTs, 0 otherwise */
358 * the rank (number of dimensions) of the
362 * the dimensions of the array to the
368 * n_before[i] = product of n[j] for j < i
370 int *n_after; /* n_after[i] = product of n[j] for j > i */
372 fftw_plan *plans; /* 1d fftw plans for each dimension */
375 fftw_complex *work; /*
376 * work array big enough to hold
377 * nbuffers+1 of the largest dimension
378 * (has nwork elements)
382 typedef fftwnd_data *fftwnd_plan;
384 /* Initializing the FFTWND plan: */
385 extern fftwnd_plan fftw2d_create_plan(int nx, int ny, fftw_direction dir,
387 extern fftwnd_plan fftw3d_create_plan(int nx, int ny, int nz,
388 fftw_direction dir, int flags);
389 extern fftwnd_plan fftwnd_create_plan(int rank, const int *n,
393 extern fftwnd_plan fftw2d_create_plan_specific(int nx, int ny,
396 fftw_complex *in, int istride,
397 fftw_complex *out, int ostride);
398 extern fftwnd_plan fftw3d_create_plan_specific(int nx, int ny, int nz,
399 fftw_direction dir, int flags,
400 fftw_complex *in, int istride,
401 fftw_complex *out, int ostride);
402 extern fftwnd_plan fftwnd_create_plan_specific(int rank, const int *n,
405 fftw_complex *in, int istride,
406 fftw_complex *out, int ostride);
408 /* Freeing the FFTWND plan: */
409 extern void fftwnd_destroy_plan(fftwnd_plan plan);
411 /* Printing the plan: */
412 extern void fftwnd_fprint_plan(FILE *f, fftwnd_plan p);
413 extern void fftwnd_print_plan(fftwnd_plan p);
414 #define FFTWND_HAS_PRINT_PLAN
416 /* Computing the N-Dimensional FFT */
417 extern void fftwnd(fftwnd_plan plan, int howmany,
418 fftw_complex *in, int istride, int idist,
419 fftw_complex *out, int ostride, int odist);
420 extern void fftwnd_one(fftwnd_plan p, fftw_complex *in, fftw_complex *out);
425 #endif /* __cplusplus */