I have an algorithm that heavily uses FFTs, and I am using Coder to generate a MEX function. However, I see that for C/C++ targets, FFT lengths must be a power of 2: http://www.mathworks.com/help/simulink/ug/functions-supported-for-code-generation–alphabetical-list.html
My algorithm needs to perform FFTs that have length CLOSE to a power of two; my algorithm naturally generates a vector with length 2^(N-1), but then because my calculations require a type-I inverse DCT, I end up passing a vector of length (2^N-2) into the FFT algorithm. Because (2^N-2) is not a power of two, I get an error about FFT lengths when using Coder in this way. The Signal Processing toolbox function "idct" doesn't do the trick either, because that's a type-II transform.
I can get around this by declaring coder.extrinsic("fft"), but then I'm not really getting the full speed benefit of C/C++ because data is being sent back into MATLAB, which presumably calls FFTW anyway to do the calculation, then passes the result back.
My question is: can I get Coder to generate C/C++ that calls FFTW directly, and link the generated MEX against the FFTW library? It seems that Coder supports this kind of thing with BLAS already, where it generates calls to BLAS and links in the library (I think). Any one out there have thoughts or experience they can share about this?
Best Answer