More templating elimination (MatchedFilter), some #include clean-up.

592 bytes!
This commit is contained in:
Jared Boone 2016-01-04 11:32:47 -08:00
parent e6f69c90f2
commit cd3a5afdb1
2 changed files with 24 additions and 12 deletions

View File

@ -21,9 +21,26 @@
#include "matched_filter.hpp" #include "matched_filter.hpp"
#include <algorithm>
#include <cmath>
#include "utility.hpp"
namespace dsp { namespace dsp {
namespace matched_filter { 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<samples_t>(taps_count);
taps_reversed_ = std::make_unique<taps_t>(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( bool MatchedFilter::execute_once(
const sample_t input const sample_t input
) { ) {

View File

@ -22,17 +22,10 @@
#ifndef __MATCHED_FILTER_H__ #ifndef __MATCHED_FILTER_H__
#define __MATCHED_FILTER_H__ #define __MATCHED_FILTER_H__
#include "utility.hpp"
#include <cstddef> #include <cstddef>
#include <complex> #include <complex>
#include <array>
#include <memory> #include <memory>
#include <algorithm>
#include <numeric>
namespace dsp { namespace dsp {
namespace matched_filter { namespace matched_filter {
@ -61,11 +54,7 @@ public:
const T& taps, const T& taps,
size_t decimation_factor size_t decimation_factor
) { ) {
samples_ = std::make_unique<samples_t>(taps.size()); configure(taps.data(), taps.size(), decimation_factor);
taps_reversed_ = std::make_unique<taps_t>(taps.size());
taps_count_ = taps.size();
decimation_factor_ = decimation_factor;
std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]);
} }
bool execute_once(const sample_t input); bool execute_once(const sample_t input);
@ -93,6 +82,12 @@ private:
bool is_new_decimation_cycle() const { bool is_new_decimation_cycle() const {
return (decimation_phase == 0); return (decimation_phase == 0);
} }
void configure(
const tap_t* const taps,
const size_t taps_count,
const size_t decimation_factor
);
}; };
} /* namespace matched_filter */ } /* namespace matched_filter */