added signum()

This commit is contained in:
Ahmet Inan 2018-09-09 20:24:14 +02:00
commit 7c19098c87
2 changed files with 25 additions and 0 deletions

View file

@ -66,3 +66,7 @@ Faster alternative (no Inf/NaN handling) to the std::complex implementation.
Mixed-radix [decimation-in-time](https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm) [fast Fourier transform](https://en.wikipedia.org/wiki/Fast_Fourier_transform)
### [utils.hh](utils.hh)
Some everyday helpers, like the [signum function](https://en.wikipedia.org/wiki/Sign_function).

21
utils.hh Normal file
View file

@ -0,0 +1,21 @@
/*
Some little helpers
Copyright 2018 Ahmet Inan <inan@aicodix.de>
*/
#ifndef UTILS_HH
#define UTILS_HH
namespace DSP {
template <typename TYPE>
int signum(TYPE v)
{
return (v > TYPE(0)) - (v < TYPE(0));
}
}
#endif