Allow setting a suffix for constants and trigonometric functions

In order to use constants or trigonometric functions with a type other than
double, a suffix ('f' for float or 'l' for long double) has to be used in C.
This commit adds a preprocessor macro 'kiss_fft_suffix' which can be set to
either 'f' or 'l' and which will be added to floating point constants and to
the trigonometric functions (sin and cos).

Without this suffix, the code will use a too high precision for float and a
too low precision for long double.
This commit is contained in:
Steffen Kieß
2019-09-24 14:16:06 +02:00
parent 1efe72041e
commit 5ebbc5e618
4 changed files with 57 additions and 7 deletions

View File

@ -49,8 +49,8 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme
kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
for (i = 0; i < nfft/2; ++i) {
double phase =
-3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5);
kiss_fft_scalar_one phase =
KISS_ADD_SUFFIX(-3.14159265358979323846264338327) * ((kiss_fft_scalar_one) (i+1) / nfft + .5);
if (inverse_fft)
phase *= -1;
kf_cexp (st->super_twiddles+i,phase);