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