0

I'm trying to get kiss fft to compile both float and double implementations in the same app using visual studio 2013. I see that all I need to do is set the kiss_fft_scalar to double and re-compile to get double.

To this end I put together a header whereby I include the headers with kiss_fft_scalar changed inside 2 different namespaces as follows:

namespace KissFloat
{
    #undef KISS_FFT_H
    #undef KISS_FTR_H
    #define kiss_fft_scalar float
    #include "kiss_fft.h"
    #include "tools/kiss_fftr.h"
};

namespace KissDouble
{
    #undef KISS_FFT_H
    #undef KISS_FTR_H
    #define kiss_fft_scalar double
    #include "kiss_fft.h"
    #include "tools/kiss_fftr.h"
};

I can't however figure out how to include the cpp code. I've tried a seperate KissFloat and KissDouble file. I've then tried a few things in the cpp file but everything I try ends up with compile errors. usually relating to struct redefinition.

Can anyone think of a way to make this work? Or am I just better off re-writing kiss fft using templates?

Goz
  • 61,365
  • 24
  • 124
  • 204

2 Answers2

1

Interesting idea, but you might have better luck just hacking on the files e.g. making kiss_fft_scalar a template parameter. One problem is that the header files will be including other header files like stdlib.h. I suppose you could pre-emptively include those files before you do your namespace trick.

I'm guessing the struct redef errors are for the kiss_fft_state in _kiss_fft_guts.h? It might work if you have separate Float/Double .cpp files and using directives before inclusion of the .c files.

If you decide to templatize it, you could take a look at the Eigen (partial) c++ port of kissfft.

Mark Borgerding
  • 8,117
  • 4
  • 30
  • 51
  • Thanks for the response ... and yeah .. I have tried the using statements. Had the same thought myself :) Sadly it didn't work :( You are right on the struct redef errors ... good idea on the pre including the headers! – Goz Mar 01 '17 at 21:56
0

So I've discovered that Eigen has done the work of templating kiss FFT for me. Yay to other people doing the hard work! ;)

Eigen is available here:

https://bitbucket.org/eigen/eigen/src

and the kiss fft implementation is under

"unsupported/Eigen/src/FFT/"

Goz
  • 61,365
  • 24
  • 124
  • 204