Re: [eigen] FFT question

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


It works when I use the raw pointer methods of FFT. It is something in the Eigen matric functions. I should have a fix in the next day or so.

-- Mark


Trevor Irons wrote:
Mark and others:

I'm trying to get the KISS FFT working for me, but am struggling a little with the Real to Complex and back case. I suspect I'm misusing it somehow, I based this off the tests. The Complex to Complex fwd and inv (Full Spectrum) are working with similar logic.

The forward operation seems to be accurate, but how do I do the inverse on 1/2 spectrum. If I don't remove the flag, I get a lot of errors at runtime (compiles fine):

g++ on 64 bit linux
*** glibc detected *** ./min: free(): invalid next size (normal): 0x0000000000da6790 ***
======= Backtrace: =========
/lib/libc.so.6[0x7fc8a700cdd6]
/lib/libc.so.6(cfree+0x6c)[0x7fc8a701174c]

If I do remove the flag, thinking that maybe since the buffer is double, it will know it is a complex to real transform, but the answer is wrong.

If a do a full spectrum all is happy.

What am I doing wrong? If possible I'd like to just use the 1/2 spectrum. Thanks for any insight, really glad to have this out of the box like this.

#include "Eigen/Core"
#include "unsupported/Eigen/FFT"
#include <complex>

typedef std::complex<double> Complex;

using namespace Eigen;
using namespace std;

int main() {
FFT<double> fft;
    double dt(1e-3);
VectorXd timeseries(200);
     VectorXcd fd(200);

     for (int i=0; i<200; ++i) {
         timeseries[i] = std::sin((double)(i)*dt*95.);
     }
fft.SetFlag(fft.HalfSpectrum );
      fft.fwd(fd, timeseries);
     VectorXd out;

    // faults if I don't remove, wrong answer if I do
     fft.ClearFlag(fft.HalfSpectrum );
     fft.inv(out, fd);

    for (int i=0; i< out.size(); ++i) {
        cout << timeseries[i] << "\t" << out[i] << endl;
    }
}




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/