31 #include <boost/iterator/reverse_iterator.hpp> 32 #include <boost/bind.hpp> 33 #include <boost/math/distributions/normal.hpp> 34 #include <boost/cstdint.hpp> 48 template <
typename TIterator,
typename TFilterIterator,
typename TOutputIterator>
52 TFilterIterator filterBeg,
54 TOutputIterator resBeg,
55 bool circular =
false,
59 typedef typename std::iterator_traits<TOutputIterator>::value_type TReal;
62 throw std::logic_error(
"filter size must be odd");
68 size_t offset =
static_cast<size_t>(fsize/2);
69 for(std::size_t i = 0 ; i< offset; ++i, ++resBeg)
71 *resBeg = std::numeric_limits<TReal>::quiet_NaN();
74 for( ; dataBeg != dataEnd - (fsize -1) ; ++dataBeg, ++resBeg )
76 *resBeg = (std::inner_product(dataBeg , dataBeg + fsize, filterBeg ,0. ));
82 std::vector<typename std::iterator_traits<TIterator>::value_type> tmp;
83 typename std::vector<typename std::iterator_traits<TIterator>::value_type>::iterator it;
86 TIterator tbegin = tmp.begin();
89 for( ; tbegin != tend - (fsize-1 ) ; ++tbegin, ++resBeg )
91 *resBeg = std::inner_product(tbegin , tbegin + fsize, filterBeg ,0. );
111 template <
typename TContainer>
113 const TContainer & data,
114 const TContainer &
filter,
116 bool circular =
false,
120 result.resize(data.size());
TContainer::iterator prepareData(TIterator dataBeg, TIterator dataEnd, size_t fsize, TContainer &res, bool mirror=false)
Example Sequence : 1 2 3 4 5; width 5 and mirror false: 4 5 1 2 3 4 5 1 2, if mirror true than: 2 1 1...
void filter_sequence(TIterator dataBeg, TIterator dataEnd, TFilterIterator filterBeg, size_t fsize, TOutputIterator resBeg, bool circular=false, uint32_t sides=2)
EQUISPACEINTERPOL Interpolation on a equidistantly spaced grid.
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.