c++visual-studiovisual-studio-2013kissfft

Compiling kiss fft with float and double support in the same app


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?


Solution

  • 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/"