help-octave
[Top][All Lists]
Advanced

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

Re: fftshift bug?


From: Ben Abbott
Subject: Re: fftshift bug?
Date: Sun, 03 Jul 2011 20:15:51 -0400

On Jul 3, 2011, at 7:51 PM, Daryl Lee wrote:

> I'm plowing through the new book "GNU Octave Beginner's Guide" and I finally 
> get to a concept I recall from graduate school--Fourier Analysis.  In the 
> process, I discovered what I took to be a bug in the fftshift function, fixed 
> it, and now I don't know what to do with what I found.
> 
> My environment: Octave 3.4.0, Mac OSX.
> 
> How to reproduce the bug:
>>> fftshift([1 2 3 4])
> 
> Expect:
> ans =
>  3 4 1 2
> 
> Got:
> error: fftshift: A(I): index out of bounds; value 150 out of bound 1
> error: called from:
> error:   
> /Applications/Octave.app/Contents/Resources/share/octave/3.4.0/m/signal/fftshift.m
>  at line 70, column 14
> 
> So I opened fftshift.m and found this sequence:
>    if (isvector (x))
>      x = length (x);
>      xx = ceil (x/2);
>      retval = x([xx+1:x 1:xx]);
> 
> I replaced this with
>    if (isvector (x))
>      X = length (x);
>      xx = ceil (X/2);
>      retval = x([xx+1:X, 1:xx]);
> 
> (I just up-cased selected occurrences of "x") and all is well.
> 
> But since I'm just getting started, I'm not sure if it's just my ignorance.  
> Could someone either confirm this or correct me?
> 
> --
> Daryl Lee
> Senior Software Engineer
> www.daryllee.com

The bug you've found has been fixed.

        http://hg.savannah.gnu.org/hgweb/octave/rev/189baf055143

Even so, thanks for reporting, and providing a solution.

Ben



reply via email to

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