digitalmars.D - FFT Lib?
- dsimcha (14/14) Jul 27 2010 I'm going to need an FFT library to perform some convolutions at some po...
- Mike James (6/26) Jul 27 2010 This is one of the best FFTs I've used...
- dsimcha (5/9) Jul 27 2010 I was aware of this, but:
- Rory Mcguire (8/28) Jul 27 2010 Hi,
- Fawzi Mohamed (10/48) Jul 27 2010 I was preceded, that is a good list. I can only say that FFTW is
- dsimcha (12/21) Jul 27 2010 This was kind of my point: Does a "simple and good enough" FFT that's O...
- Fawzi Mohamed (12/43) Jul 27 2010 about belonging to phobos I don't know, but it would be useful.
- Don (7/14) Jul 27 2010 What does "simple" mean?
- Fawzi Mohamed (11/30) Jul 28 2010 and cache awarness..., but yes efficiently supporting arbitrary
- dsimcha (9/18) Jul 28 2010 Yeh, I only need powers of two. I realize this isn't very hard because ...
- Don (3/24) Jul 28 2010 I believe that a moderately efficient cache-aware FFT could be made
- Philippe Sigaud (5/13) Jul 28 2010 You have my vote, David. As long as it does 2D FFT, it'll cover the vast
- jtravs (5/19) Jul 28 2010 You should have a look at kissfft. It is very small (one short c file), ...
- dsimcha (9/28) Jul 28 2010 work. I'm willing to help with a D version too, if you want, as I might ...
- Fawzi Mohamed (5/49) Jul 29 2010 otherwise, as I already said http://www.netlib.org/fftpack/fft.c is
- dsimcha (9/13) Jul 29 2010 Yeah, I just looked at this code. The problem is that I wouldn't do a s...
- Fawzi Mohamed (10/31) Jul 30 2010 eheh this must meant that too much fortran inured me, I did not find
- dsimcha (20/52) Jul 30 2010 Yes, but typical numerics intensive code is basically unreadable. I thi...
- Fawzi Mohamed (16/32) Jul 30 2010 The main thing that you should probably do (apart documenting the
- Don (3/58) Jul 31 2010 This is a useful read on FFT performance.
- bearophile (6/8) Jul 31 2010 That looks good, but it's also a large amount of information.
- Mike James (5/72) Aug 02 2010 Fixed-point FFTs could be important if your number-crunching data that c...
I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port? 3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?
Jul 27 2010
"dsimcha" <dsimcha yahoo.com> wrote in message news:i2na5q$2kgi$1 digitalmars.com...I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port? 3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?This is one of the best FFTs I've used... http://www.fftw.org/ I don't know whether the licence is ok for you. -=mike=-
Jul 27 2010
== Quote from Mike James (foo bar.com)'s articleThis is one of the best FFTs I've used... http://www.fftw.org/ I don't know whether the licence is ok for you. -=mike=-I was aware of this, but: 1. GPL 2. "every microoptimization", not "simple and good enough", so it would likely be a PITA to port. This doesn't matter anyhow, though, because of (1).
Jul 27 2010
dsimcha wrote:I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port? 3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?Hi, I haven't used fft for anything before not sure what I'd use it for either, here is public domain code claiming to be a fft: http://www.dsprelated.com/showmessage/36380/1.php And here is a list of fft libs: http://fftw.org/benchfft/ffts.html -Rory
Jul 27 2010
On 27-lug-10, at 21:47, Rory Mcguire wrote:dsimcha wrote:I was preceded, that is a good list. I can only say that FFTW is *really* good, and if you structure your code well you should be able to support more than one library. I have wrappers for fftw, and it can be used with NArray (N dimensional dense arrays in blip), but is not directly there exactly due to the license. So having a fallback FFT would be useful for me. ciao FawziI'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port? 3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?Hi, I haven't used fft for anything before not sure what I'd use it for either, here is public domain code claiming to be a fft: http://www.dsprelated.com/showmessage/36380/1.php And here is a list of fft libs: http://fftw.org/benchfft/ffts.html -Rory
Jul 27 2010
== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleI was preceded, that is a good list. I can only say that FFTW is *really* good, and if you structure your code well you should be able to support more than one library. I have wrappers for fftw, and it can be used with NArray (N dimensional dense arrays in blip), but is not directly there exactly due to the license. So having a fallback FFT would be useful for me. ciao FawziThis was kind of my point: Does a "simple and good enough" FFT that's O(N log N) but not super optimized and maybe works on generic ranges and ranges of ranges belong in Phobos? The idea is that if you just need a few FFTs here and there, convenience is important, and they're not a major bottleneck for you, you use Phobos. If you need the absolute best even if it has to be installed separately, is under a more restrictive license, is more of a PITA to use, etc., you use FFTW or something. My use case, to give a little more detail as an example, is that I want to add kernel density estimation to dstats. I need a reasonably efficient way to compute a convolution, but not super-optimized pedal-to-the-metal ones, and I need to not have to add a dependency to dstats just for this and for the license to be compatible.
Jul 27 2010
On 27-lug-10, at 23:28, dsimcha wrote:== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleabout belonging to phobos I don't know, but it would be useful. The program I am working on will be GPL, so I don't have problems with fftw, still the fftw binding is one place where I know that I should work more...I was preceded, that is a good list. I can only say that FFTW is *really* good, and if you structure your code well you should be able to support more than one library. I have wrappers for fftw, and it can be used with NArray (N dimensional dense arrays in blip), but is not directly there exactly due to the license. So having a fallback FFT would be useful for me. ciao FawziThis was kind of my point: Does a "simple and good enough" FFT that's O(N log N) but not super optimized and maybe works on generic ranges and ranges of ranges belong in Phobos? The idea is that if you just need a few FFTs here and there, convenience is important, and they're not a major bottleneck for you, you use Phobos. If you need the absolute best even if it has to be installed separately, is under a more restrictive license, is more of a PITA to use, etc., you use FFTW or something.My use case, to give a little more detail as an example, is that I want to add kernel density estimation to dstats. I need a reasonably efficient way to compute a convolution, but not super-optimized pedal-to-the-metal ones, and I need to not have to add a dependency to dstats just for this and for the license to be compatible.I understand, I need more performance from the fft. I know numpy uses fftpack, but that is fortran, but it has a c version, probably not the best choice to have a maintanable code, but the .c version is small, see http://www.netlib.org/fftpack/ fawzi
Jul 27 2010
dsimcha wrote:I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough"What does "simple" mean? If you're happy with lengths being restricted to powers of 2, it's simple. Most of the complexity of something like FFTW comes from support for arbitrary lengths.3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?I think that a basic power-of-2 FFT is simple enough, and sufficiently widely used to be worth including.
Jul 27 2010
On 28-lug-10, at 06:22, Don wrote:dsimcha wrote:and cache awarness..., but yes efficiently supporting arbitrary lengths is difficult.I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough"What does "simple" mean? If you're happy with lengths being restricted to powers of 2, it's simple. Most of the complexity of something like FFTW comes from support for arbitrary lengths.Note that the fft from fftpack support arbitrary lengths (the efficiency decreases, but not so drastically). I would put something like that for "casual" use, so that one doesn't have to worry too much about sizes. If he needs something better then he should start to worry about it. For example one could have a routine returning the next "good" size, always increasing. Fawzi3. If I do end up writing my own or porting, is there sufficient interest in this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?I think that a basic power-of-2 FFT is simple enough, and sufficiently widely used to be worth including.
Jul 28 2010
== Quote from Don (nospam nospam.com)'s articledsimcha wrote:Yeh, I only need powers of two. I realize this isn't very hard because I wrote a prototype of it a while back. However, this prototype would basically need to be rewritten b/c: 1. It only supports pure real inputs, meaning you can't use it to compute inverse FFTs. 2. I tried to write it using strides instead of rearranging the elements of the arrays, mostly because I was curious what effect this would have on performance. It turned out to be disastrous, presumably because it killed cache efficiency.I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough"What does "simple" mean? If you're happy with lengths being restricted to powers of 2, it's simple. Most of the complexity of something like FFTW comes from support for arbitrary lengths.
Jul 28 2010
dsimcha wrote:== Quote from Don (nospam nospam.com)'s articleI believe that a moderately efficient cache-aware FFT could be made using simple blocking with the info from core.cpuid.dsimcha wrote:Yeh, I only need powers of two. I realize this isn't very hard because I wrote a prototype of it a while back. However, this prototype would basically need to be rewritten b/c: 1. It only supports pure real inputs, meaning you can't use it to compute inverse FFTs. 2. I tried to write it using strides instead of rearranging the elements of the arrays, mostly because I was curious what effect this would have on performance. It turned out to be disastrous, presumably because it killed cache efficiency.I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough"What does "simple" mean? If you're happy with lengths being restricted to powers of 2, it's simple. Most of the complexity of something like FFTW comes from support for arbitrary lengths.
Jul 28 2010
3. If I do end up writing my own or porting, is there sufficient interestYou have my vote, David. As long as it does 2D FFT, it'll cover the vast majority of my own needs. And FFT is exactly the kind of things I need regularly, but only a few times a year. Having it in std.numerics would be excellent. Philippein this that I should try to target it for std.numerics, or would I be better off just making it good enough for my use case?I think that a basic power-of-2 FFT is simple enough, and sufficiently widely used to be worth including.
Jul 28 2010
dsimcha Wrote:I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port?You should have a look at kissfft. It is very small (one short c file), appropriately licensed and supports arbitrary sizes quite efficiently. I have recently ported this to the go programming language in just a few hours work. I'm willing to help with a D version too, if you want, as I might also need this soon. kissfft can be found at: http://kissfft.sourceforge.net J
Jul 28 2010
== Quote from jtravs (jtravs gmail.com)'s articledsimcha Wrote:appropriately licensed and supports arbitrary sizes quite efficiently.I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port?You should have a look at kissfft. It is very small (one short c file),I have recently ported this to the go programming language in just a few hourswork. I'm willing to help with a D version too, if you want, as I might also need this soon.kissfft can be found at: http://kissfft.sourceforge.net JThis looks great except that the license requires binary attribution. I've emailed the author and asked him to waive the binary attribution requirement and let me use it under the Boost license for the purpose of a D port. If he goes for it, I'll probably just port this code to D for std.numeric, and then use it where I need to in dstats. Otherwise, it's back to square 1.
Jul 28 2010
On 29-lug-10, at 00:01, dsimcha wrote:== Quote from jtravs (jtravs gmail.com)'s articleotherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... Fawzidsimcha Wrote:appropriately licensed and supports arbitrary sizes quite efficiently.I'm going to need an FFT library to perform some convolutions at some point soon. Two absolute, non-negotiable requirements are that it be written in pure D and that it be Boost or compatibly (i.e. zlib or public domain) licensed. I also prefer "simple and good enough" over "has every micro-optimization in the book but a PITA to maintain/modify/use", as long as it's at least a true fft as opposed to an O(N^2) DFT. A few questions: 1. Does anyone already have such a lib? 2. If noone has one I'll probably either write my own from scratch or port some code from C if I can find code that's under a suitable license and written with a "simple and good enough" philosophy rather than an "every tiny optimization in the book" philosophy. Could anyone recommend one to port?You should have a look at kissfft. It is very small (one short c file),I have recently ported this to the go programming language in just a few hourswork. I'm willing to help with a D version too, if you want, as I might also need this soon.kissfft can be found at: http://kissfft.sourceforge.net JThis looks great except that the license requires binary attribution. I've emailed the author and asked him to waive the binary attribution requirement and let me use it under the Boost license for the purpose of a D port. If he goes for it, I'll probably just port this code to D for std.numeric, and then use it where I need to in dstats. Otherwise, it's back to square 1.
Jul 29 2010
== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleotherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... FawziYeah, I just looked at this code. The problem is that I wouldn't do a straight, mechanical port to D, I'd D-ify the code a little while I was at it (such as making it work on generic random access ranges if it's an out of place transform, making real-only inputs vs. complex inputs DRYer with templates, etc.). Since this code seems to have been straight-up translated from FORTRAN, it scores about a -2 the readability scale, from 1 to 10. In other words, I would probably be able to translate it and make it run, but even the slightest modification would be near impossible.
Jul 29 2010
On 29-lug-10, at 15:31, dsimcha wrote:== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleeheh this must meant that too much fortran inured me, I did not find the code too bad, I classified it as a typical numerical intensive code (even rather clean where one can easily find the boundaries of the arrays, and without too many goto), and templating float, using slices as input seemed easy. But yes probably it is not the best basis to develop your own thing. Ahrg fortran ruined me ;). ciao Fawziotherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... FawziYeah, I just looked at this code. The problem is that I wouldn't do a straight, mechanical port to D, I'd D-ify the code a little while I was at it (such as making it work on generic random access ranges if it's an out of place transform, making real-only inputs vs. complex inputs DRYer with templates, etc.). Since this code seems to have been straight-up translated from FORTRAN, it scores about a -2 the readability scale, from 1 to 10. In other words, I would probably be able to translate it and make it run, but even the slightest modification would be near impossible.
Jul 30 2010
== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleOn 29-lug-10, at 15:31, dsimcha wrote:Yes, but typical numerics intensive code is basically unreadable. I think D is about the only language that has enough high-level stuff (templates, etc.) to write readable numerics code with a nice interface, but is also efficient enough to write efficient numerics code. Unfortunately, we're basically starting from scratch because C and Fortran numerics code is so crufty and unreadable that it's really, really hard to refactor it into readable D or even put a nice interface on it.== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleeheh this must meant that too much fortran inured me, I did not find the code too bad, I classified it as a typical numerical intensive code (even rather clean where one can easily find the boundaries of the arrays, and without too many goto), and templating float, using slices as input seemed easy.otherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... FawziYeah, I just looked at this code. The problem is that I wouldn't do a straight, mechanical port to D, I'd D-ify the code a little while I was at it (such as making it work on generic random access ranges if it's an out of place transform, making real-only inputs vs. complex inputs DRYer with templates, etc.). Since this code seems to have been straight-up translated from FORTRAN, it scores about a -2 the readability scale, from 1 to 10. In other words, I would probably be able to translate it and make it run, but even the slightest modification would be near impossible.But yes probably it is not the best basis to develop your own thing. Ahrg fortran ruined me ;). ciao FawziI got permission from Mark Borgerding to port kissfft and have the binary attribution clause waived, but unfortunately this code is almost as difficult to read due to its extreme preprocessor abuse. (Basically he implements complex numbers as a struct with an imaginary and real component and a bunch of preprocessor macros.) Part of the preprocessor abuse is necessary for supporting fixed point FFTs. Does anyone care about these (I sure don't), or can I just get rid of them? I'm hoping I can refactor this code into a nice D interface, but it may end up being that I have to basically start from scratch. One thing I will absolutely not do is contribute code without a proper D-style (i.e. templated, works with std.complex, etc.) interface. If I can't understand kissfft well enough to do this refactoring, then maybe I'll just start from scratch using the Wikipedia FFT article and a textbook.
Jul 30 2010
On 30-lug-10, at 16:14, dsimcha wrote:[...] Part of the preprocessor abuse is necessary for supporting fixed point FFTs. Does anyone care about these (I sure don't), or can I just get rid of them?I don't care about themI'm hoping I can refactor this code into a nice D interface, but it may end up being that I have to basically start from scratch. One thing I will absolutely not do is contribute code without a proper D-style (i.e. templated, works with std.complex, etc.) interface. If I can't understand kissfft well enough to do this refactoring, then maybe I'll just start from scratch using the Wikipedia FFT article and a textbook.The main thing that you should probably do (apart documenting the factors and order that you assume/generate) is splitting fft in initialization of a given size (creating a struct/ class environment) and executing an fft of that size (which might be a method of the environment (probably better) or a free function taking the env as parameter). Both fftpack (http://www.netlib.org/fftpack/doc) and fftw (http://fftw.org/doc/ ) have that structure. This because you can prepare/precompute things to then do the actual fft in the optimal way. Then you can still provide easy to use wrappers that call the two things in sequence. ciao Fawzi
Jul 30 2010
dsimcha wrote:== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleThis is a useful read on FFT performance. http://cnx.org/content/m16336/latest/On 29-lug-10, at 15:31, dsimcha wrote:Yes, but typical numerics intensive code is basically unreadable. I think D is about the only language that has enough high-level stuff (templates, etc.) to write readable numerics code with a nice interface, but is also efficient enough to write efficient numerics code. Unfortunately, we're basically starting from scratch because C and Fortran numerics code is so crufty and unreadable that it's really, really hard to refactor it into readable D or even put a nice interface on it.== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleeheh this must meant that too much fortran inured me, I did not find the code too bad, I classified it as a typical numerical intensive code (even rather clean where one can easily find the boundaries of the arrays, and without too many goto), and templating float, using slices as input seemed easy.otherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... FawziYeah, I just looked at this code. The problem is that I wouldn't do a straight, mechanical port to D, I'd D-ify the code a little while I was at it (such as making it work on generic random access ranges if it's an out of place transform, making real-only inputs vs. complex inputs DRYer with templates, etc.). Since this code seems to have been straight-up translated from FORTRAN, it scores about a -2 the readability scale, from 1 to 10. In other words, I would probably be able to translate it and make it run, but even the slightest modification would be near impossible.But yes probably it is not the best basis to develop your own thing. Ahrg fortran ruined me ;). ciao FawziI got permission from Mark Borgerding to port kissfft and have the binary attribution clause waived, but unfortunately this code is almost as difficult to read due to its extreme preprocessor abuse. (Basically he implements complex numbers as a struct with an imaginary and real component and a bunch of preprocessor macros.) Part of the preprocessor abuse is necessary for supporting fixed point FFTs. Does anyone care about these (I sure don't), or can I just get rid of them? I'm hoping I can refactor this code into a nice D interface, but it may end up being that I have to basically start from scratch. One thing I will absolutely not do is contribute code without a proper D-style (i.e. templated, works with std.complex, etc.) interface. If I can't understand kissfft well enough to do this refactoring, then maybe I'll just start from scratch using the Wikipedia FFT article and a textbook.
Jul 31 2010
Don:This is a useful read on FFT performance. http://cnx.org/content/m16336/latest/That looks good, but it's also a large amount of information. Register allocation (spilling strategy) is critical in not uber-optimized FFT routines. And GPUs can help :-) Bye, bearophile
Jul 31 2010
"dsimcha" <dsimcha yahoo.com> wrote in message news:i2umov$2esa$1 digitalmars.com...== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleFixed-point FFTs could be important if your number-crunching data that could have been collected by, say, a microcontroller-based system with 16-bit ADCs. Integer-only FFTs are useful.On 29-lug-10, at 15:31, dsimcha wrote:Yes, but typical numerics intensive code is basically unreadable. I think D is about the only language that has enough high-level stuff (templates, etc.) to write readable numerics code with a nice interface, but is also efficient enough to write efficient numerics code. Unfortunately, we're basically starting from scratch because C and Fortran numerics code is so crufty and unreadable that it's really, really hard to refactor it into readable D or even put a nice interface on it.== Quote from Fawzi Mohamed (fawzi gmx.ch)'s articleeheh this must meant that too much fortran inured me, I did not find the code too bad, I classified it as a typical numerical intensive code (even rather clean where one can easily find the boundaries of the arrays, and without too many goto), and templating float, using slices as input seemed easy.otherwise, as I already said http://www.netlib.org/fftpack/fft.c is public domain, has reasonable performance, and supports all sizes. It might not be the always beautiful, but it is stable and works well... FawziYeah, I just looked at this code. The problem is that I wouldn't do a straight, mechanical port to D, I'd D-ify the code a little while I was at it (such as making it work on generic random access ranges if it's an out of place transform, making real-only inputs vs. complex inputs DRYer with templates, etc.). Since this code seems to have been straight-up translated from FORTRAN, it scores about a -2 the readability scale, from 1 to 10. In other words, I would probably be able to translate it and make it run, but even the slightest modification would be near impossible.But yes probably it is not the best basis to develop your own thing. Ahrg fortran ruined me ;). ciao FawziI got permission from Mark Borgerding to port kissfft and have the binary attribution clause waived, but unfortunately this code is almost as difficult to read due to its extreme preprocessor abuse. (Basically he implements complex numbers as a struct with an imaginary and real component and a bunch of preprocessor macros.) Part of the preprocessor abuse is necessary for supporting fixed point FFTs. Does anyone care about these (I sure don't), or can I just get rid of them?I'm hoping I can refactor this code into a nice D interface, but it may end up being that I have to basically start from scratch. One thing I will absolutely not do is contribute code without a proper D-style (i.e. templated, works with std.complex, etc.) interface. If I can't understand kissfft well enough to do this refactoring, then maybe I'll just start from scratch using the Wikipedia FFT article and a textbook.
Aug 02 2010