|Re: [eigen] A complex FFT for Eigen|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] A complex FFT for Eigen
- From: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 27 Nov 2008 16:26:48 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=faGcGVt8LODjORmyEPTJzvqEVO5MY/rdGLJAQ1dyomY=; b=pIIWk+p1+rdaRIE0gCVH9eobyRGdcWKTDk/kPhgpzGzOGQj2rmOTJFHkUyN16rzOAr ryXXej4w6qpxtJR6rnfN93Hiv83LBA4hWpNBfKGg76d17APGQaoHrtgTUL6Ja59+o4OL kGX19vweUbxYY8jeJUIL9/NXZ6uLEzvmqfn2k=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=h7bTD2WyYNUnYWxMPvL1l3RM8RXMFvtvGS7D7NjkPgRVaHuicXfxnI3vTFXnIO6itI /hh5/d8pIaMJ8aSa6Hvdug7vJ536D9otyRqcxjq789cqlJ/dD4LT9hrl9MHBAxx+x1u7 4TlVxQh7+LQyDbhZziqLA6QA0VDSRbLfLkC6M=
Thank you for your interest and your code, it's at least interesting to read.
Eigen is a linear algebra library, so FFT is beyond its basic scope,
but we do have a couple of modules doing non-linear-algebra stuff
(Eigen/Regression and Eigen/Geometry) so FFT is not ruled out at that
I lack knowledge on FFT actually to make a decision whether or not we
want it inside Eigen:
- is it usual to restrict it to complex numbers and power-of-two fixed
sizes ? Wouldn't it be desirable to allow reals, to allow any
non-pow-of-2 size, to allow dynamic-size? If any is "yes" then we need
it before inclusion in Eigen
- your code doesn't leverage Eigen as much as it could to enable high
performance. For example, in apply(), replacing the for loop by single
operations on vectors would let Eigen handle loop unrolling and
vectorization. Well, except that Eigen doesn't vectorize std::complex
currently, so I wonder if your code should be adapted to that or if
this means that we should consider vectorizing std::complex. (So far
we haven't seen many uses for std::complex anyway so we didn't
optimize it as much as we maybe could).
- the factorize() function here is not vectorizable at all because it
doesn't do any contiguous access. Aren't there other, more
data /= n; is optimized by Eigen as *= 1/n.
> I did run into one issue, which is how to create an eigen object that refers into a vector nicely (there is a TODO in the code at the point where this would be nice to have). I ended up using pointers into the arrays :(
Not sure if that's your question, but, for lack of template typedefs
in C++98, there is no nicer way to refer to general N-vectors than
Matrix<Scalar, N, 1>. Eigen doesn't have a Vector class, vectors are
matrices. Note there are typedefs like Vector3f, VectorXf etc. We're
looking forward to C++0x ;)
2008/11/27 Tim Molteno <tim@xxxxxxxxxxxxxxxxxxx>:
> Eigen is great. Thanks to everyone who has done so much work on it.
> I've written a complex fft algorithm for eigen. It uses template
> metaprogramming, and is fairly snappy.
> It defines a templated class CFFT, and here is how to use it.
> #define LOG_LENGTH 13
> #define N 1<<LOG_LENGTH
> CFFT<LOG_LENGTH, double> gfft;
> Matrix<fft_complex, LENGTH, 1> cdata;
> gfft.fft(cdata); // Forward transform
> gfft.ifft(cdata); // Reverse transform
> I did run into one issue, which is how to create an eigen object that refers
> into a vector nicely (there is a TODO in the code at the point where this
> would be nice to have). I ended up using pointers into the arrays :(
> Anyway, I have licensed it under the GPL 3 at the moment, please let me know
> if you'd like to include this in Eigen. I can arrange testharness code, and
> would welcome suggestions for improvements.
> Tim Molteno
> Physics Department
> University of Otago