void *fftw_malloc(size_t n); void fftw_free(void *p);
These are functions that behave identically to
free, except that they guarantee that the returned pointer obeys
any special alignment restrictions imposed by any algorithm in FFTW
(e.g. for SIMD acceleration). See SIMD alignment and fftw_malloc.
Data allocated by
fftw_malloc must be deallocated by
fftw_free and not by the ordinary
These routines simply call through to your operating system’s
malloc or, if necessary, its aligned equivalent
memalign), so you normally need not worry about any
significant time or space overhead. You are not required to use
them to allocate your data, but we strongly recommend it.
Note: in C++, just as with ordinary
malloc, you must typecast
the output of
fftw_malloc to whatever pointer type you are
We also provide the following two convenience functions to allocate
real and complex arrays with
n elements, which are equivalent
(double *) fftw_malloc(sizeof(double) * n) and
(fftw_complex *) fftw_malloc(sizeof(fftw_complex) * n),
double *fftw_alloc_real(size_t n); fftw_complex *fftw_alloc_complex(size_t n);
The equivalent functions in other precisions allocate arrays of
elements in that precision. e.g.
(float *) fftwf_malloc(sizeof(float) * n).