From: Phil on
Hi again, I just thought I'd give feedback about how I went on with this.

In the end I had to use the visual studio compiler. Matlab's lcc compiler and cygwin did not work correctly since the functions in the fftw libraries could not be linked. Just use visual studio to produce the .lib files from the .dll's and .def's downloaded from www.fftw.org (there is documentation on how to do this).

However, this did not solve all problems. Unfortunately even when fftw was working I discovered a serious memory leak. Basically it looks like when the fftw functions are called and memory is allocated away from the mex code it will not be freed on return (since the libraries most likely use free() instead of mxFree()). This is fine as long as you don't do too many fft's and have plenty of RAM.

The problem for me is that I am doing lots of fft's (wavelet analysis) so in the end I had to turn to calling matlab's own fft function via:

mxArray *input,*output[1]
....
mexCallMATLAB(1, output, 1, &input, "fft");
outxr=mxGetPr(outx[0]);
....
mxDestroyArray(input); mxDestroyArray(output[0]);

Using this method is undoubtedly going to be slower but there are absolutely no memory leaks, which is probably more important for most applications.

Anyway, hope that's useful for anyone who's been having the same problems.
From: kk KKsingh on
Can you give step wise description of how you compiled FFTW with MATLAB using visual studio .....Try to put this in steps ..I m doing some thing wrong some where.....


"Phil " <waofy(a)hotmail.com> wrote in message <ho0b5r$mbs$1(a)fred.mathworks.com>...
> Hi again, I just thought I'd give feedback about how I went on with this.
>
> In the end I had to use the visual studio compiler. Matlab's lcc compiler and cygwin did not work correctly since the functions in the fftw libraries could not be linked. Just use visual studio to produce the .lib files from the .dll's and .def's downloaded from www.fftw.org (there is documentation on how to do this).
>
> However, this did not solve all problems. Unfortunately even when fftw was working I discovered a serious memory leak. Basically it looks like when the fftw functions are called and memory is allocated away from the mex code it will not be freed on return (since the libraries most likely use free() instead of mxFree()). This is fine as long as you don't do too many fft's and have plenty of RAM.
>
> The problem for me is that I am doing lots of fft's (wavelet analysis) so in the end I had to turn to calling matlab's own fft function via:
>
> mxArray *input,*output[1]
> ...
> mexCallMATLAB(1, output, 1, &input, "fft");
> outxr=mxGetPr(outx[0]);
> ...
> mxDestroyArray(input); mxDestroyArray(output[0]);
>
> Using this method is undoubtedly going to be slower but there are absolutely no memory leaks, which is probably more important for most applications.
>
> Anyway, hope that's useful for anyone who's been having the same problems.
From: kk KKsingh on
I tried with windows Cygwin gcc FFTW -- Sucessfull
I tried with linux gcc FFTW -- Sucessfull
Now working with VS FFTW -- will update soon .....

Now question is what is best to go with matlab


tristram.scott(a)ntlworld.com (Tristram Scott) wrote in message <2qQbn.13687$TS3.12413(a)newsfe13.ams2>...
> kk aKI <akikumar1983(a)gmail.com> wrote:
> [snip]
>
> > Well I easily compiled with CYGWIN ..but i dont know how to access it
> > through matlab
>
> With a mex wrapper, as described in the External Interfaces manual. You
> will need to include the fftw header files, and link against the fftw
> libraries.
>
> If you post your example code, the commands you are running, and the errors
> you get, perhaps someone can help you further.
>
> --
> Dr Tristram J. Scott
> Energy Consultant