views:

10374

answers:

7

Where can I find a free, very quick, and reliable implementation of FFT in C#? Can be used in a product? or are there any restrictions?

+6  A: 

This is a free .Net (open-source) library with Fast Fourier Transform support. (See ComplexImage.cs for implemenation)

http://code.google.com/p/aforge/

torial
+2  A: 

http://www.exocortex.org/dsp/ is an open-source C# mathematics library with FFT algorithms.

pookleblinky
Limited to only a few transform sizes.
Jon Harrop
+6  A: 

Math.NET's Iridium library provides a fast, regularly updated collection of math-related functions, including the FFT. It's licensed under the LGPL so you are free to use it in commercial products.

Jacob
+7  A: 

The guy that did AForge did a fairly good job but it's not commercial quality. It's great to learn from but you can tell he was learning too so he has some pretty serious mistakes like assuming the size of an image instead of using the correct bits per pixel.

I'm not knocking the guy, I respect the heck out of him for learning all that and show us how to do it. I think he's a Ph.D now or at least he's about to be so he's really smart it's just not a commercially usable library.

The Math.Net library has its own weirdness when working with Fourier transforms and complex images/numbers. Like, if I'm not mistaken, it outputs the Fourier transform in human viewable format which is nice for humans if you want to look at a picture of the transform but it's not so good when you are expecting the data to be in a certain format (the normal format). I could be mistaken about that but I just remember there was some weirdness so I actually went to the original code they used for the Fourier stuff and it worked much better. (ExocortexDSP v1.2 http://www.exocortex.org/dsp/)

Math.net also had some other funkyness I didn't like when dealing with the data from the FFT, I can't remember what it was I just know it was much easier to get what I wanted out of the ExoCortex DSP library. I'm not a mathematician or engineer though; to those guys it might make perfect sense.

So! I use the FFT code yanked from ExoCortex, which Math.Net is based on, without anything else and it works great.

And finally, I know it's not C#, but I've started looking at using FFTW (http://www.fftw.org/). And this guy already made a C# wrapper so I was going to check it out but haven't actually used it yet. (http://www.sdss.jhu.edu/~tamas/bytes/fftwcsharp.html)

OH! I don't know if you are doing this for school or work but either way there is a GREAT free lecture series given by a Stanford professor on iTunes University.

http://deimos3.apple.com/WebObjects/Core.woa/Browse/itunes.stanford.edu.1617315771

Mike Bethany
I'd be interested in more details about the weirdness in the Math.NET Iridium fft implementation - so we can fix it! ;). Is it related to how complex numbers are handled? No idea what you mean with the "human viewable format" though. Samples: http://mathnet.opensourcedotnet.info/doc/IridiumFFT.ashx
Christoph Rüegg
Hey, sorry for the poor communication. By human viewable I mean if you were to take the values from the FFT and make a picture out of it. With a "natural" FFT you will have the white spots in the outer corners. In the "human viewable" that data is in the center, like a star or circle.
Mike Bethany
Again sorry for my poor communication I'm just learning this stuff so don't have the tools to properly describe what I mean. I'm probably just not understanding something in the library.
Mike Bethany
fftw has some kind of problematic license; check this out: "Non-free licenses for FFTW are also available that permit different terms of use than the GPL."
Daniel Mošmondor
+3  A: 

Just a comment on @Jacob and @pookleblinky: Iridiums fft is built on exocortex but has some wrapping and tweaking around it which, in fact, makes it run slower. So if it is a pure fft computation needed I would stick with exocortex's fft package.

Jonas Hallgren
There is actually a comment button you know.
edude05
not if you don't have enough rep
advs89
+1 so you have some rep now :)
Trap
Lovely, thanks a lot :D
Jonas Hallgren
A: 

For a multi-threaded implementation tuned for Intel processors I'd check out Intel's MKL library. It's not free, but it's afforable (less than $100) and blazing fast - but you'd need to call it's C dll's via P/Invokes. The Exocortex project stopped development 6 years ago, so I'd be careful using it if this is an important project.

Paul
CenterSpace Software
www.centerspace.net

Paul
+1  A: 

Here's another; a C# port of the Ooura FFT. It's reasonably fast. The package also includes overlap/add convolution and some other DSP stuff, under the MIT license.

http://github.com/hughpyle/inguz-DSPUtil/commits/master/Fourier.cs

Hugh