From 7c19098c87ca9cdda19d4f7fd78f517050191149 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 9 Sep 2018 20:24:14 +0200 Subject: [PATCH] added signum() --- README.md | 4 ++++ utils.hh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 utils.hh diff --git a/README.md b/README.md index df177db..0499d2a 100644 --- a/README.md +++ b/README.md @@ -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). + diff --git a/utils.hh b/utils.hh new file mode 100644 index 0000000..a0549ec --- /dev/null +++ b/utils.hh @@ -0,0 +1,21 @@ +/* +Some little helpers + +Copyright 2018 Ahmet Inan +*/ + +#ifndef UTILS_HH +#define UTILS_HH + +namespace DSP { + +template +int signum(TYPE v) +{ + return (v > TYPE(0)) - (v < TYPE(0)); +} + +} + +#endif +