[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] FFT question
- From: Trevor Irons <trevorirons@xxxxxxxxx>
- Date: Mon, 15 Feb 2010 19:53:00 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=wFUg4Ue/cacbgiORVXsjxGRbpRlOOc9ElKxV+isuleA=; b=NsZmrvcbmduc7zXVVTzdtPd+KXdP+2woW8wNwzgcRVrg4O6n89+KhJ+sLQnhT6e1iC qd+kRBIgbGZhUYndkpRNuYUArXV97dbUWSe7epL1hDRzYJfojdUFqpH0ljyRfn1IsmAU lS4PdfgldaEcRMUwxp0vLyq1693vxToohLMnk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=eQseo+jvGJf+i6FY32qJnDjqnyHUjg7vws6xSm9ssRNPyZMtGFeLPvFNPHC73IsmYE 9J5hAwoRacWq7eo8NVnSBAXImaFi1CuBIHDYmzw4OVWALFoJ/Vy+Ya/57mTiyur5h1cg bLxHr5aIXN08KnoXcJttrPfObxm0F7TNxuSLI=
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;
}
}