Chris@10: Chris@10: Chris@10: Memory Allocation - FFTW 3.3.3 Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10:
Chris@10: Chris@10:

Chris@10: Previous: Precision, Chris@10: Up: Data Types and Files Chris@10:


Chris@10:
Chris@10: Chris@10:

4.1.3 Memory Allocation

Chris@10: Chris@10:
     void *fftw_malloc(size_t n);
Chris@10:      void fftw_free(void *p);
Chris@10: 
Chris@10:

Chris@10: These are functions that behave identically to malloc and Chris@10: free, except that they guarantee that the returned pointer obeys Chris@10: any special alignment restrictions imposed by any algorithm in FFTW Chris@10: (e.g. for SIMD acceleration). See SIMD alignment and fftw_malloc. Chris@10: Chris@10: Chris@10:

Data allocated by fftw_malloc must be deallocated by Chris@10: fftw_free and not by the ordinary free. Chris@10: Chris@10:

These routines simply call through to your operating system's Chris@10: malloc or, if necessary, its aligned equivalent Chris@10: (e.g. memalign), so you normally need not worry about any Chris@10: significant time or space overhead. You are not required to use Chris@10: them to allocate your data, but we strongly recommend it. Chris@10: Chris@10:

Note: in C++, just as with ordinary malloc, you must typecast Chris@10: the output of fftw_malloc to whatever pointer type you are Chris@10: allocating. Chris@10: Chris@10: Chris@10:

We also provide the following two convenience functions to allocate Chris@10: real and complex arrays with n elements, which are equivalent Chris@10: to (double *) fftw_malloc(sizeof(double) * n) and Chris@10: (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * n), Chris@10: respectively: Chris@10: Chris@10:

     double *fftw_alloc_real(size_t n);
Chris@10:      fftw_complex *fftw_alloc_complex(size_t n);
Chris@10: 
Chris@10:

Chris@10: The equivalent functions in other precisions allocate arrays of n Chris@10: elements in that precision. e.g. fftwf_alloc_real(n) is Chris@10: equivalent to (float *) fftwf_malloc(sizeof(float) * n). Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: