Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

fftw.h

Go to the documentation of this file.
00001 /* fftw/fftw.h.  Generated automatically by configure.  */
00002 /* -*- C -*- */
00003 /*
00004  * Copyright (c) 1997-1999 Massachusetts Institute of Technology
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 /* fftw.h -- system-wide definitions */
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                          /* __cplusplus */
00033 
00034 /* Define for using single precision */
00035 /*
00036  * If you can, use configure --enable-float instead of changing this
00037  * flag directly 
00038  */
00039 #define FFTW_ENABLE_FLOAT 1
00040 
00041 /* our real numbers */
00042 #ifdef FFTW_ENABLE_FLOAT
00043 typedef float fftw_real;
00044 #else
00045 typedef double fftw_real;
00046 #endif
00047 
00048 /*********************************************
00049  * Complex numbers and operations 
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 /* backward compatibility with FFTW-1.3 */
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 /* backward compatibility with FFTW-1.0 */
00072 #define REAL fftw_real
00073 #define COMPLEX fftw_complex
00074 #endif
00075 
00076 /*********************************************
00077  * Success or failure status
00078  *********************************************/
00079 
00080 typedef enum {
00081      FFTW_SUCCESS = 0, FFTW_FAILURE = -1
00082 } fftw_status;
00083 
00084 /*********************************************
00085  *              Codelets
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  *     Configurations
00110  *********************************************/
00111 /*
00112  * A configuration is a database of all known codelets
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 /* description of a codelet */
00121 typedef struct {
00122      const char *name;          /* name of the codelet */
00123      void (*codelet) ();        /* pointer to the codelet itself */
00124      int size;                  /* size of the codelet */
00125      fftw_direction dir;        /* direction */
00126      enum fftw_node_type type;  /* TWIDDLE or NO_TWIDDLE */
00127      int signature;             /* unique id */
00128      int ntwiddle;              /* number of twiddle factors */
00129      const int *twiddle_order;  /* 
00130                                  * array that determines the order 
00131                                  * in which the codelet expects
00132                                  * the twiddle factors
00133                                  */
00134 } fftw_codelet_desc;
00135 
00136 /* On Win32, you need to do funny things to access global variables
00137    in shared libraries.  Thanks to Andrew Sterian for this hack. */
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  *        Plans
00154  *****************************/
00155 /*
00156  * A plan is a sequence of reductions to compute a FFT of
00157  * a given size.  At each step, the FFT algorithm can:
00158  *
00159  * 1) apply a notw codelet, or
00160  * 2) recurse and apply a twiddle codelet, or
00161  * 3) apply the generic codelet.
00162  */
00163 
00164 /* structure that contains twiddle factors */
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 /* structure that holds all the data needed for a given step */
00187 typedef struct fftw_plan_node_struct {
00188      enum fftw_node_type type;
00189 
00190      union {
00191           /* nodes of type FFTW_NOTW */
00192           struct {
00193                int size;
00194                fftw_notw_codelet *codelet;
00195                const fftw_codelet_desc *codelet_desc;
00196           } notw;
00197 
00198           /* nodes of type FFTW_TWIDDLE */
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           /* nodes of type FFTW_GENERIC */
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           /* nodes of type FFTW_RADER */
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           /* nodes of type FFTW_REAL2HC */
00225           struct {
00226                int size;
00227                fftw_real2hc_codelet *codelet;
00228                const fftw_codelet_desc *codelet_desc;
00229           } real2hc;
00230 
00231           /* nodes of type FFTW_HC2REAL */
00232           struct {
00233                int size;
00234                fftw_hc2real_codelet *codelet;
00235                const fftw_codelet_desc *codelet_desc;
00236           } hc2real;
00237 
00238           /* nodes of type FFTW_HC2HC */
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           /* nodes of type FFTW_RGENERIC */
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 /* flags for the planner */
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)  /* guarantee plan is read-only so that the
00291                                   same plan can be used in parallel by
00292                                   multiple threads */
00293 
00294 #define FFTWND_FORCE_BUFFERED (256)     /* internal flag, forces buffering
00295                                            in fftwnd transforms */
00296 
00297 #define FFTW_NO_VECTOR_RECURSE (512)    /* internal flag, prevents use
00298                                            of vector recursion */
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 /*=========== RWCox: omit the malloc.c file ==========*/
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     /* nada */
00326 #  define fftw_print_max_memory_usage /* nada */
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 /* Wisdom: */
00340 /*
00341  * define this symbol so that users know we are using a version of FFTW
00342  * with wisdom
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  * define symbol so we know this function is available (it is not in
00355  * older FFTWs)
00356  */
00357 #define FFTW_HAS_FPRINT_PLAN
00358 extern void fftw_fprint_plan(FILE *f, fftw_plan plan);
00359 
00360 /*****************************
00361  *    N-dimensional code
00362  *****************************/
00363 typedef struct {
00364      int is_in_place;           /* 1 if for in-place FFTs, 0 otherwise */
00365 
00366      int rank;                  /* 
00367                                  * the rank (number of dimensions) of the
00368                                  * array to be FFTed 
00369                                  */
00370      int *n;                    /*
00371                                  * the dimensions of the array to the
00372                                  * FFTed 
00373                                  */
00374      fftw_direction dir;
00375 
00376      int *n_before;             /*
00377                                  * n_before[i] = product of n[j] for j < i 
00378                                  */
00379      int *n_after;              /* n_after[i] = product of n[j] for j > i */
00380 
00381      fftw_plan *plans;          /* 1d fftw plans for each dimension */
00382 
00383      int nbuffers, nwork;
00384      fftw_complex *work;        /* 
00385                                  * work array big enough to hold
00386                                  * nbuffers+1 of the largest dimension 
00387                                  * (has nwork elements)
00388                                  */
00389 } fftwnd_data;
00390 
00391 typedef fftwnd_data *fftwnd_plan;
00392 
00393 /* Initializing the FFTWND plan: */
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 /* Freeing the FFTWND plan: */
00418 extern void fftwnd_destroy_plan(fftwnd_plan plan);
00419 
00420 /* Printing the plan: */
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 /* Computing the N-Dimensional FFT */
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 }                               /* extern "C" */
00433 
00434 #endif                          /* __cplusplus */
00435 #endif                          /* FFTW_H */
 

Powered by Plone

This site conforms to the following standards: