cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: FFTW 3.3.8: Memory Allocation cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: cannam@167:
cannam@167:

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

cannam@167:
cannam@167:
cannam@167: cannam@167:

4.1.3 Memory Allocation

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

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

cannam@167: cannam@167:

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

cannam@167:

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

cannam@167:

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

cannam@167: cannam@167:

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

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

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

cannam@167: cannam@167: cannam@167: cannam@167: cannam@167: