DiFipp/include/GenericFilter.h

39 wiersze
935 B
C
Czysty Zwykły widok Historia

2018-10-23 01:16:10 +00:00
#pragma once
#include "type_checks.h"
2018-10-23 01:16:10 +00:00
#include <stddef.h>
#include <vector>
2018-10-23 10:22:57 +00:00
namespace fratio {
template <typename T>
class GenericFilter {
static_assert(std::is_floating_point<T>::value && !std::is_const<T>::value, "Only accept non-complex floating point types.");
2018-10-23 10:22:57 +00:00
public:
T stepFilter(T data);
std::vector<T> filter(const std::vector<T>& data);
2018-10-23 10:22:57 +00:00
void resetFilter();
void getCoeff(std::vector<T>& aCoeff, std::vector<T>& bCoeff) const noexcept;
2018-10-23 10:22:57 +00:00
protected:
GenericFilter() = default;
GenericFilter(const std::vector<T>& aCoeff, const std::vector<T>& bCoeff);
virtual ~GenericFilter() = default;
void checkCoeff(const std::vector<T>& aCoeff, const std::vector<T>& bCoeff);
2018-10-23 10:22:57 +00:00
void normalize();
protected:
std::vector<T> m_aCoeff;
std::vector<T> m_bCoeff;
2018-10-23 10:22:57 +00:00
private:
std::vector<T> m_filteredData;
std::vector<T> m_rawData;
2018-10-23 10:22:57 +00:00
};
} // namespace fratio
#include "GenericFilter.inl"