Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: FFTW 3.3.5: Memory Allocation Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42:
Chris@42:

Chris@42: Previous: , Up: Data Types and Files   [Contents][Index]

Chris@42:
Chris@42:
Chris@42: Chris@42:

4.1.3 Memory Allocation

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

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

Chris@42: Chris@42:

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

Chris@42:

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

Chris@42:

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

Chris@42: Chris@42:

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

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

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

Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: