eDSP  0.0.1
A cross-platform DSP library written in C++.
azcr.hpp
Go to the documentation of this file.
1 
27 #ifndef EDSP_AZCR_HPP
28 #define EDSP_AZCR_HPP
29 
30 #include <edsp/math/numeric.hpp>
31 #include <iterator>
32 
33 namespace edsp { namespace feature { inline namespace temporal {
34 
35 
52  template <typename InputIt, typename OutputIt>
53  constexpr void amdf(InputIt first, InputIt last, OutputIt d_first) {
54  using value_type = typename std::iterator_traits<OutputIt>::value_type;
55  value_type accumulated = 0;
56  for (++first; first != last;) {
57  accumulated += math::sign(*first) != math::sign(*(first - 1));
58  }
59  return accumulated / static_cast<value_type>(std::distance(first, last));
60  }
61 
62 
63 }}}
64 
65 #endif //EDSP_AZCR_HPP
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr void amdf(InputIt first, InputIt last, OutputIt d_first)
Computes the AMDF (Average Magnitude Difference Function) of the contiguous elements in the range [fi...
Definition: amdf.hpp:51
constexpr T sign(T x) noexcept
Determines the sign of the input number.
Definition: numeric.hpp:155
Definition: amplifier.hpp:29