I am using MATLAB coder to generate code which deals with complex numbers. The default typedef for the complex type generated by MATLAB is:
typedef double real_T;//real number
typedef struct {
real_T re;
real_T im;
} creal_T;//complex number
Now, I want to use fftw3 to perform fft on the data, the problem is that in fftw3 the complex type is defined as:
typedef double fftw_complex[2];
From the fftw3 documentaion in the "Upgrading from fftw Version 2" section:
The main difference in data types is that fftw_complex in FFTW 2 was defined as a struct with macros c_re and c_im for accessing the real/imaginary parts. (This is binary compatible with FFTW 3 on any machine except perhaps for some older Crays in single precision.) The equivalent macros for FFTW 3 are:
#define c_re(c) ((c)[0]) #define c_im(c) ((c)[1])
Am I missing something here or is there a way to cast, safely, the creal_T type to the corresponding fftw3 without actually copying the data element by element?