Code and installation instructions at:
https://github.com/mjibson/go-dsp
Corrections and
suggestions are appreciated.
I'll look into package comments and godocs. Thanks for the notes.
If it is called concurrently, the worst
that could happen is some things are computed twice, but all
assignments can be run in any order, and the result should be the
same.
Still though, locks are probably a good idea. Will do.
a few other thoughts in addition to Jan's (please take with a pinch
of salt - i've never used FFT in anger):
- it looks like quite a few of the functions don't deserve
to be exported. the ones i'm thinking of are:
ToComplex, IsPowerOf2, NextPowerOf2, ZeroPad and ZeroPad2,
and perhaps even RadixFFT and BluesteinFFT given
that they're invoked appropriately as necessary.
- FFT_real might be better spelt "FFTFloat". In general variable
names in Go use camelCase rather than underscore separators.
e.g. input_len would conventionally be spelt inputLen.
- this code:
if _, present := n2_factors[input_len]; !present {
could more concisely be written as
if n2_factors[input_len] == nil {
because you will never add a nil map to n2_factors.
- you might want to use a sync.RWMutex to
guard the factors map.
What is the best way to easily support float32?
I suggest automating the production of the code with a little scripting magic to avoid the copy-paste problem, but however you do it you will, at least for now, have two copies of the implementation.
-rob
Look more closely, the radix-2 function is Cooley-Tukey.