2 * Copyright (c) 2003, 2007-8 Matteo Frigo
3 * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology
5 * The following statement of license applies *only* to this header file,
6 * and *not* to the other files distributed with FFTW or derived therefrom:
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 /***************************** NOTE TO USERS *********************************
34 * THIS IS A HEADER FILE, NOT A MANUAL
36 * If you want to know how to use FFTW, please read the manual,
37 * online at http://www.fftw.org/doc/ and also included with FFTW.
38 * For a quick start, see the manual's tutorial section.
40 * (Reading header files to learn how to use a library is a habit
41 * stemming from code lacking a proper manual. Arguably, it's a
42 * *bad* habit in most cases, because header files can contain
43 * interfaces that are not part of the public, stable API.)
45 ****************************************************************************/
55 #endif /* __cplusplus */
57 /* If <complex.h> is included, use the C99 complex type. Otherwise
58 define a type bit-compatible with C99 complex */
59 #if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I)
60 # define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C
62 # define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2]
65 #define FFTW_CONCAT(prefix, name) prefix ## name
66 #define FFTW_MANGLE_DOUBLE(name) FFTW_CONCAT(fftw_, name)
67 #define FFTW_MANGLE_FLOAT(name) FFTW_CONCAT(fftwf_, name)
68 #define FFTW_MANGLE_LONG_DOUBLE(name) FFTW_CONCAT(fftwl_, name)
70 /* IMPORTANT: for Windows compilers, you should add a line
72 here and in kernel/ifftw.h if you are compiling/using FFTW as a
73 DLL, in order to do the proper importing/exporting, or
74 alternatively compile with -DFFTW_DLL or the equivalent
75 command-line flag. This is not necessary under MinGW/Cygwin, where
76 libtool does the imports/exports automatically. */
77 #if defined(FFTW_DLL) && (defined(_WIN32) || defined(__WIN32__))
78 /* annoying Windows syntax for shared-library declarations */
79 # if defined(COMPILING_FFTW) /* defined in api.h when compiling FFTW */
80 # define FFTW_EXTERN extern __declspec(dllexport)
81 # else /* user is calling FFTW; import symbol */
82 # define FFTW_EXTERN extern __declspec(dllimport)
85 # define FFTW_EXTERN extern
88 enum fftw_r2r_kind_do_not_use_me {
89 FFTW_R2HC=0, FFTW_HC2R=1, FFTW_DHT=2,
90 FFTW_REDFT00=3, FFTW_REDFT01=4, FFTW_REDFT10=5, FFTW_REDFT11=6,
91 FFTW_RODFT00=7, FFTW_RODFT01=8, FFTW_RODFT10=9, FFTW_RODFT11=10
94 struct fftw_iodim_do_not_use_me {
95 int n; /* dimension size */
96 int is; /* input stride */
97 int os; /* output stride */
100 #include <stddef.h> /* for ptrdiff_t */
101 struct fftw_iodim64_do_not_use_me {
102 ptrdiff_t n; /* dimension size */
103 ptrdiff_t is; /* input stride */
104 ptrdiff_t os; /* output stride */
108 huge second-order macro that defines prototypes for all API
109 functions. We expand this macro for each supported precision
111 X: name-mangling macro
116 #define FFTW_DEFINE_API(X, R, C) \
118 FFTW_DEFINE_COMPLEX(R, C); \
120 typedef struct X(plan_s) *X(plan); \
122 typedef struct fftw_iodim_do_not_use_me X(iodim); \
123 typedef struct fftw_iodim64_do_not_use_me X(iodim64); \
125 typedef enum fftw_r2r_kind_do_not_use_me X(r2r_kind); \
127 FFTW_EXTERN void X(execute)(const X(plan) p); \
129 FFTW_EXTERN X(plan) X(plan_dft)(int rank, const int *n, \
130 C *in, C *out, int sign, unsigned flags); \
132 FFTW_EXTERN X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, \
134 FFTW_EXTERN X(plan) X(plan_dft_2d)(int n0, int n1, \
135 C *in, C *out, int sign, unsigned flags); \
136 FFTW_EXTERN X(plan) X(plan_dft_3d)(int n0, int n1, int n2, \
137 C *in, C *out, int sign, unsigned flags); \
139 FFTW_EXTERN X(plan) X(plan_many_dft)(int rank, const int *n, \
141 C *in, const int *inembed, \
142 int istride, int idist, \
143 C *out, const int *onembed, \
144 int ostride, int odist, \
145 int sign, unsigned flags); \
147 FFTW_EXTERN X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, \
149 const X(iodim) *howmany_dims, \
151 int sign, unsigned flags); \
152 FFTW_EXTERN X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, \
154 const X(iodim) *howmany_dims, \
155 R *ri, R *ii, R *ro, R *io, \
158 FFTW_EXTERN X(plan) X(plan_guru64_dft)(int rank, \
159 const X(iodim64) *dims, \
161 const X(iodim64) *howmany_dims, \
163 int sign, unsigned flags); \
164 FFTW_EXTERN X(plan) X(plan_guru64_split_dft)(int rank, \
165 const X(iodim64) *dims, \
167 const X(iodim64) *howmany_dims, \
168 R *ri, R *ii, R *ro, R *io, \
171 FFTW_EXTERN void X(execute_dft)(const X(plan) p, C *in, C *out); \
172 FFTW_EXTERN void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, \
175 FFTW_EXTERN X(plan) X(plan_many_dft_r2c)(int rank, const int *n, \
177 R *in, const int *inembed, \
178 int istride, int idist, \
179 C *out, const int *onembed, \
180 int ostride, int odist, \
183 FFTW_EXTERN X(plan) X(plan_dft_r2c)(int rank, const int *n, \
184 R *in, C *out, unsigned flags); \
186 FFTW_EXTERN X(plan) X(plan_dft_r2c_1d)(int n,R *in,C *out,unsigned flags); \
187 FFTW_EXTERN X(plan) X(plan_dft_r2c_2d)(int n0, int n1, \
188 R *in, C *out, unsigned flags); \
189 FFTW_EXTERN X(plan) X(plan_dft_r2c_3d)(int n0, int n1, \
191 R *in, C *out, unsigned flags); \
194 FFTW_EXTERN X(plan) X(plan_many_dft_c2r)(int rank, const int *n, \
196 C *in, const int *inembed, \
197 int istride, int idist, \
198 R *out, const int *onembed, \
199 int ostride, int odist, \
202 FFTW_EXTERN X(plan) X(plan_dft_c2r)(int rank, const int *n, \
203 C *in, R *out, unsigned flags); \
205 FFTW_EXTERN X(plan) X(plan_dft_c2r_1d)(int n,C *in,R *out,unsigned flags); \
206 FFTW_EXTERN X(plan) X(plan_dft_c2r_2d)(int n0, int n1, \
207 C *in, R *out, unsigned flags); \
208 FFTW_EXTERN X(plan) X(plan_dft_c2r_3d)(int n0, int n1, \
210 C *in, R *out, unsigned flags); \
212 FFTW_EXTERN X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, \
214 const X(iodim) *howmany_dims, \
217 FFTW_EXTERN X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, \
219 const X(iodim) *howmany_dims, \
223 FFTW_EXTERN X(plan) X(plan_guru_split_dft_r2c)( \
224 int rank, const X(iodim) *dims, \
226 const X(iodim) *howmany_dims, \
227 R *in, R *ro, R *io, \
229 FFTW_EXTERN X(plan) X(plan_guru_split_dft_c2r)( \
230 int rank, const X(iodim) *dims, \
232 const X(iodim) *howmany_dims, \
233 R *ri, R *ii, R *out, \
236 FFTW_EXTERN X(plan) X(plan_guru64_dft_r2c)(int rank, \
237 const X(iodim64) *dims, \
239 const X(iodim64) *howmany_dims, \
242 FFTW_EXTERN X(plan) X(plan_guru64_dft_c2r)(int rank, \
243 const X(iodim64) *dims, \
245 const X(iodim64) *howmany_dims, \
249 FFTW_EXTERN X(plan) X(plan_guru64_split_dft_r2c)( \
250 int rank, const X(iodim64) *dims, \
252 const X(iodim64) *howmany_dims, \
253 R *in, R *ro, R *io, \
255 FFTW_EXTERN X(plan) X(plan_guru64_split_dft_c2r)( \
256 int rank, const X(iodim64) *dims, \
258 const X(iodim64) *howmany_dims, \
259 R *ri, R *ii, R *out, \
262 FFTW_EXTERN void X(execute_dft_r2c)(const X(plan) p, R *in, C *out); \
263 FFTW_EXTERN void X(execute_dft_c2r)(const X(plan) p, C *in, R *out); \
265 FFTW_EXTERN void X(execute_split_dft_r2c)(const X(plan) p, \
266 R *in, R *ro, R *io); \
267 FFTW_EXTERN void X(execute_split_dft_c2r)(const X(plan) p, \
268 R *ri, R *ii, R *out); \
270 FFTW_EXTERN X(plan) X(plan_many_r2r)(int rank, const int *n, \
272 R *in, const int *inembed, \
273 int istride, int idist, \
274 R *out, const int *onembed, \
275 int ostride, int odist, \
276 const X(r2r_kind) *kind, unsigned flags); \
278 FFTW_EXTERN X(plan) X(plan_r2r)(int rank, const int *n, R *in, R *out, \
279 const X(r2r_kind) *kind, unsigned flags); \
281 FFTW_EXTERN X(plan) X(plan_r2r_1d)(int n, R *in, R *out, \
282 X(r2r_kind) kind, unsigned flags); \
283 FFTW_EXTERN X(plan) X(plan_r2r_2d)(int n0, int n1, R *in, R *out, \
284 X(r2r_kind) kind0, X(r2r_kind) kind1, \
286 FFTW_EXTERN X(plan) X(plan_r2r_3d)(int n0, int n1, int n2, \
287 R *in, R *out, X(r2r_kind) kind0, \
288 X(r2r_kind) kind1, X(r2r_kind) kind2, \
291 FFTW_EXTERN X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, \
293 const X(iodim) *howmany_dims, \
295 const X(r2r_kind) *kind, unsigned flags); \
297 FFTW_EXTERN X(plan) X(plan_guru64_r2r)(int rank, const X(iodim64) *dims, \
299 const X(iodim64) *howmany_dims, \
301 const X(r2r_kind) *kind, unsigned flags); \
303 FFTW_EXTERN void X(execute_r2r)(const X(plan) p, R *in, R *out); \
305 FFTW_EXTERN void X(destroy_plan)(X(plan) p); \
306 FFTW_EXTERN void X(forget_wisdom)(void); \
307 FFTW_EXTERN void X(cleanup)(void); \
309 FFTW_EXTERN void X(set_timelimit)(double); \
311 FFTW_EXTERN void X(plan_with_nthreads)(int nthreads); \
312 FFTW_EXTERN int X(init_threads)(void); \
313 FFTW_EXTERN void X(cleanup_threads)(void); \
315 FFTW_EXTERN void X(export_wisdom_to_file)(FILE *output_file); \
316 FFTW_EXTERN char *X(export_wisdom_to_string)(void); \
317 FFTW_EXTERN void X(export_wisdom)(void (*write_char)(char c, void *), \
319 FFTW_EXTERN int X(import_system_wisdom)(void); \
320 FFTW_EXTERN int X(import_wisdom_from_file)(FILE *input_file); \
321 FFTW_EXTERN int X(import_wisdom_from_string)(const char *input_string); \
322 FFTW_EXTERN int X(import_wisdom)(int (*read_char)(void *), void *data); \
324 FFTW_EXTERN void X(fprint_plan)(const X(plan) p, FILE *output_file); \
325 FFTW_EXTERN void X(print_plan)(const X(plan) p); \
327 FFTW_EXTERN void *X(malloc)(size_t n); \
328 FFTW_EXTERN void X(free)(void *p); \
330 FFTW_EXTERN void X(flops)(const X(plan) p, \
331 double *add, double *mul, double *fmas); \
332 FFTW_EXTERN double X(estimate_cost)(const X(plan) p); \
334 FFTW_EXTERN const char X(version)[]; \
335 FFTW_EXTERN const char X(cc)[]; \
336 FFTW_EXTERN const char X(codelet_optim)[];
339 /* end of FFTW_DEFINE_API macro */
341 FFTW_DEFINE_API(FFTW_MANGLE_DOUBLE, double, fftw_complex)
342 FFTW_DEFINE_API(FFTW_MANGLE_FLOAT, float, fftwf_complex)
343 FFTW_DEFINE_API(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex)
345 #define FFTW_FORWARD (-1)
346 #define FFTW_BACKWARD (+1)
348 #define FFTW_NO_TIMELIMIT (-1.0)
350 /* documented flags */
351 #define FFTW_MEASURE (0U)
352 #define FFTW_DESTROY_INPUT (1U << 0)
353 #define FFTW_UNALIGNED (1U << 1)
354 #define FFTW_CONSERVE_MEMORY (1U << 2)
355 #define FFTW_EXHAUSTIVE (1U << 3) /* NO_EXHAUSTIVE is default */
356 #define FFTW_PRESERVE_INPUT (1U << 4) /* cancels FFTW_DESTROY_INPUT */
357 #define FFTW_PATIENT (1U << 5) /* IMPATIENT is default */
358 #define FFTW_ESTIMATE (1U << 6)
360 /* undocumented beyond-guru flags */
361 #define FFTW_ESTIMATE_PATIENT (1U << 7)
362 #define FFTW_BELIEVE_PCOST (1U << 8)
363 #define FFTW_NO_DFT_R2HC (1U << 9)
364 #define FFTW_NO_NONTHREADED (1U << 10)
365 #define FFTW_NO_BUFFERING (1U << 11)
366 #define FFTW_NO_INDIRECT_OP (1U << 12)
367 #define FFTW_ALLOW_LARGE_GENERIC (1U << 13) /* NO_LARGE_GENERIC is default */
368 #define FFTW_NO_RANK_SPLITS (1U << 14)
369 #define FFTW_NO_VRANK_SPLITS (1U << 15)
370 #define FFTW_NO_VRECURSE (1U << 16)
371 #define FFTW_NO_SIMD (1U << 17)
372 #define FFTW_NO_SLOW (1U << 18)
373 #define FFTW_NO_FIXED_RADIX_LARGE_N (1U << 19)
374 #define FFTW_ALLOW_PRUNING (1U << 20)
375 #define FFTW_WISDOM_ONLY (1U << 21)
379 #endif /* __cplusplus */