From cd3a5afdb1c41225a7c9e982aa310dd57700b4e9 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 4 Jan 2016 11:32:47 -0800 Subject: [PATCH] More templating elimination (MatchedFilter), some #include clean-up. 592 bytes! --- firmware/baseband/matched_filter.cpp | 17 +++++++++++++++++ firmware/baseband/matched_filter.hpp | 19 +++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/firmware/baseband/matched_filter.cpp b/firmware/baseband/matched_filter.cpp index 5040349a..511410df 100644 --- a/firmware/baseband/matched_filter.cpp +++ b/firmware/baseband/matched_filter.cpp @@ -21,9 +21,26 @@ #include "matched_filter.hpp" +#include +#include + +#include "utility.hpp" + namespace dsp { namespace matched_filter { +void MatchedFilter::configure( + const tap_t* const taps, + const size_t taps_count, + const size_t decimation_factor +) { + samples_ = std::make_unique(taps_count); + taps_reversed_ = std::make_unique(taps_count); + taps_count_ = taps_count; + decimation_factor_ = decimation_factor; + std::reverse_copy(&taps[0], &taps[taps_count], &taps_reversed_[0]); +} + bool MatchedFilter::execute_once( const sample_t input ) { diff --git a/firmware/baseband/matched_filter.hpp b/firmware/baseband/matched_filter.hpp index 741f5018..d3ee30be 100644 --- a/firmware/baseband/matched_filter.hpp +++ b/firmware/baseband/matched_filter.hpp @@ -22,17 +22,10 @@ #ifndef __MATCHED_FILTER_H__ #define __MATCHED_FILTER_H__ -#include "utility.hpp" - #include - #include -#include #include -#include -#include - namespace dsp { namespace matched_filter { @@ -61,11 +54,7 @@ public: const T& taps, size_t decimation_factor ) { - samples_ = std::make_unique(taps.size()); - taps_reversed_ = std::make_unique(taps.size()); - taps_count_ = taps.size(); - decimation_factor_ = decimation_factor; - std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]); + configure(taps.data(), taps.size(), decimation_factor); } bool execute_once(const sample_t input); @@ -93,6 +82,12 @@ private: bool is_new_decimation_cycle() const { return (decimation_phase == 0); } + + void configure( + const tap_t* const taps, + const size_t taps_count, + const size_t decimation_factor + ); }; } /* namespace matched_filter */