diff options
author | Roland Stigge <stigge@antcom.de> | 2019-02-17 14:53:33 +0100 |
---|---|---|
committer | Roland Stigge <stigge@antcom.de> | 2019-02-17 14:53:33 +0100 |
commit | 308a53c389cdc2631860f434989cd57efbf91145 (patch) | |
tree | 2eadba9413a881045caedd589cc9aec7fda40134 /util.cpp | |
parent | fef594c82518a8fe4c96794852c1fc849c0ed3b3 (diff) |
Implemented Tuner
Diffstat (limited to 'util.cpp')
-rw-r--r-- | util.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util.cpp b/util.cpp new file mode 100644 index 0000000..2a81823 --- /dev/null +++ b/util.cpp @@ -0,0 +1,25 @@ +#include "util.h" + +bool RIT::is_power_of_two(unsigned int n) { + return n != 0 && (n & (n - 1)) == 0; +} + +std::vector<double> RIT::magnitudes(const std::vector<std::complex<double>>& v) { + std::vector<double> result(v.size()); + std::transform(std::begin(v), std::end(v), std::begin(result), std::abs<double>); + return result; +} + +/// size: fft size in sample points, power of 2 +int RIT::bitreverse(int i, int size) { + int result{0}; + + while (size > 1) { + result <<= 1; + result |= i & 1; + i >>= 1; + size >>= 1; + } + + return result; +} |