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)
|
Thu 08 Sep 2016 05:36:07 AM UTC, original submission:
wrong result:
crash:
my version:
|