help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Minor bug in fftw planner


From: Stephen Montgomery-Smith
Subject: Re: Minor bug in fftw planner
Date: Thu, 06 Jun 2013 13:28:47 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

On 06/06/2013 01:16 PM, Sukanta Basu wrote:
> Hi,
> 
> I believe I have detected a minor bug in fftw.
> 
> The first time (after starting octave), the following code is run, it
> creates minor differences between f1 and f2. The differences can be
> seen in the pcolor plots.
> %-----------------------------
> u  = randn(128);
> 
> fftw('planner','estimate');
> fftw('planner','estimate');
> f1 = fft2(u);
> 
> fftw('planner','exhaustive');
> fftw('planner','exhaustive');
> f2 = fft2(u);
> 
> figure(1); pcolor(real(f1-f2)); colorbar;
> figure(2); pcolor(imag(f1-f2)); colorbar;
> %-----------------------------
> However, if one repeats the exact same code for the second time (or
> more), the differences disappear.
> 
> Best,
> Sukanta

I think this is related.  I had a similar issue when I used fftw in C
code I wrote.  I wrote to the fftw people, and they said this was to be
expected.  The FFT is doing the same calculations as the discrete
Fourier transform.  But it is doing the calculations in a different
order, to get the speed increase.

But different times that you call fftw with the "estimate" parameter, it
might come up with a different plan as to how to rearrange the
operations.  So you should expect small differences in the answers each
time because of floating point rounding errors.

As to why there are no differences the second time - now that is more of
a mystery.  I have some suspicions as to why this is the case, but that
would involve me looking at the code.  But the idea is that if you call
fftw once with 'exhaustive', then it takes really long time the first
time to figure out the best way to compute fft.  Then after that it
remembers how it was done the first time.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]