bugGNU Octave - Bugs: bug #49026, function fft return wrong result...

 
 

bug #49026: function fft return wrong result or crash if n=1 and dim>2

Submitted by:  None
Submitted on:  Thu 08 Sep 2016 05:36:07 AM UTC  
 
Category: Octave FunctionSeverity: 4 - Important
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: None
Originator Name: Originator Email: -unavailable-
Open/Closed: ClosedRelease: 4.0.3
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 24 Oct 2016 04:35:18 PM UTC, comment #4:

I ran through the original examples again, no segfaults or FPEs now, and results look good at a glance, thanks for taking care of this.

Mike Miller <mtmiller>
Project Administrator
Mon 24 Oct 2016 04:05:34 PM UTC, comment #3:

I committed the patch on the stable branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/655157b34a9f) since I hate to see segfaults.

Fixed, closing report.

Rik <rik5>
Project Administrator
Fri 21 Oct 2016 07:11:23 PM UTC, comment #2:

The problem seems to be in do_fft in libinterp/corefcn/fft.cc. I quote the code, along for the first case for real FFT of single matrices.

The original array was a 4-D array (2x4x2x2). The call to fft

has asked to use just a single point along the fourth (last) dimension. In the C++ code,

the final dimension is set to 1 so the new dimensions are 2x4x2x1.

Eventually, nda.resize is called, and Octave knows to trim singleton dimensions, so the matrix becomes a 3-D matrix 2x4x2. You can check and find that fft works correctly when the dimension is not the trailing dimension.

That's the problem. I can see a few solutions. First, from someone who understands the FFT well, if I take an FFT with a single point, is the result really just an indexing operation? In this example

If that is the case, then maybe we can implement that equivalent index operation on an octave_value in C++ only when n_points == 1. This wouldn't be too much of a hassle because there is already a special case for n_points == 0.

Second, maybe there is a way to resize an array and avoid trimming singleton dimensions.

Third, and least interesting, each fourier and ifourier routine in liboctave needs to be updated to handle this special case.

I'm attaching a patch that works for me. Mike, can you test it?

Since this is a crash I would apply it to the stable branch if it passes QC.

(file #38789)

Rik <rik5>
Project Administrator
Thu 08 Sep 2016 06:18:19 PM UTC, comment #1:

I do get the same incorrect results, and I get the floating point exception only when running octave-cli, not when liboctgui is loaded. Confirmed in both 4.0.3 and default branch.

Mike Miller <mtmiller>
Project Administrator
Thu 08 Sep 2016 05:36:07 AM UTC, original submission:

wrong result:

crash:

my version:

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #38789:  fft.cset added by rik5 (5KiB - application/octet-stream)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 21 Nov 2016 10:10:39 PM UTCrik5Dependencies-=>bugs #43673 is dependent
    Mon 24 Oct 2016 04:05:34 PM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Fri 21 Oct 2016 07:11:23 PM UTCrik5Attached File-=>Added fft.cset, #38789
      StatusConfirmed=>Patch Submitted
    Thu 08 Sep 2016 06:18:19 PM UTCmtmillerSeverity3 - Normal=>4 - Important
      Item GroupIncorrect Result=>Segfault, Bus Error, etc.
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1