M17: Golay24 code cleanup

pull/1370/head
f4exb 2022-07-27 23:27:01 +02:00
rodzic b5b6bdf825
commit 06a0f051e9
2 zmienionych plików z 17 dodań i 21 usunięć

Wyświetl plik

@ -14,27 +14,12 @@ namespace modemm17
template <size_t N = 32>
struct FrequencyError
{
using float_type = float;
using array_t = std::array<float, N>;
using filter_type = BaseIirFilter<3>;
static constexpr std::array<float, 3> evm_b{0.02008337, 0.04016673, 0.02008337};
static constexpr std::array<float, 3> evm_a{1.0, -1.56101808, 0.64135154};
array_t samples_{0};
size_t index_ = 0;
float_type accum_ = 0.0;
filter_type filter_{makeIirFilter(evm_b, evm_a)};
const float_type ZERO = 0.0;
FrequencyError()
FrequencyError() :
{
samples_.fill(0.0);
samples_.fill(0.0f);
}
auto operator()(float_type sample)
auto operator()(float sample)
{
float evm = 0;
bool use = true;
@ -61,6 +46,17 @@ struct FrequencyError
return filter_(accum_ / N);
}
private:
static constexpr std::array<float, 3> evm_b{0.02008337, 0.04016673, 0.02008337};
static constexpr std::array<float, 3> evm_a{1.0, -1.56101808, 0.64135154};
std::array<float, N> samples_;
size_t index_ = 0;
float accum_ = 0.0f;
BaseIirFilter<3> filter_{makeIirFilter(evm_b, evm_a)};
const float ZERO = 0.0f;
};
} // modemm17

Wyświetl plik

@ -22,7 +22,7 @@ namespace Golay24_detail
// Need a constexpr sort.
// https://stackoverflow.com/a/40030044/854133
template<class T>
constexpr void swap(T& l, T& r)
static void swap(T& l, T& r)
{
T tmp = std::move(l);
l = std::move(r);
@ -52,7 +52,7 @@ struct array
};
template <typename T, size_t N>
constexpr void sort_impl(array<T, N> &array, size_t left, size_t right)
static void sort_impl(array<T, N> &array, size_t left, size_t right)
{
if (left < right)
{
@ -70,7 +70,7 @@ constexpr void sort_impl(array<T, N> &array, size_t left, size_t right)
}
template <typename T, size_t N>
constexpr array<T, N> sort(array<T, N> array)
static array<T, N> sort(array<T, N> array)
{
auto sorted = array;
sort_impl(sorted, 0, N);