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