cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: FFTW 3.3.5: Memory Allocation cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: cannam@127:
cannam@127:

cannam@127: Previous: , Up: Data Types and Files   [Contents][Index]

cannam@127:
cannam@127:
cannam@127: cannam@127:

4.1.3 Memory Allocation

cannam@127: cannam@127:
cannam@127:
void *fftw_malloc(size_t n);
cannam@127: void fftw_free(void *p);
cannam@127: 
cannam@127: cannam@127: cannam@127: cannam@127:

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

cannam@127: cannam@127:

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

cannam@127:

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

cannam@127:

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

cannam@127: cannam@127:

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

cannam@127:
cannam@127:
double *fftw_alloc_real(size_t n);
cannam@127: fftw_complex *fftw_alloc_complex(size_t n);
cannam@127: 
cannam@127: cannam@127: cannam@127: cannam@127:

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

cannam@127: cannam@127: cannam@127: cannam@127: cannam@127: