22 #ifndef EDSP_STATISTICAL_PEAK_HPP 23 #define EDSP_STATISTICAL_PEAK_HPP 25 #include <edsp/meta/iterator.hpp> 28 namespace edsp {
namespace statistics {
37 template <
typename ForwardIt>
38 constexpr
auto peak(ForwardIt first, ForwardIt last)
39 -> std::pair<typename meta::diff_type_t<ForwardIt>,
typename meta::value_type_t<ForwardIt>> {
40 const auto iter = std::max_element(first, last);
51 template <
typename ForwardIt>
52 constexpr
auto peakabs(ForwardIt first, ForwardIt last)
53 -> std::pair<typename meta::diff_type_t<ForwardIt>,
typename meta::value_type_t<ForwardIt>> {
54 using input_t = meta::value_type_t<ForwardIt>;
55 const auto comp = [](
const input_t left,
const input_t right) {
return std::abs(left) < std::abs(right); };
56 const auto iter = std::max_element(first, last, comp);
62 #endif // EDSP_STATISTICAL_PEAK_HPP constexpr auto peak(ForwardIt first, ForwardIt last) -> std::pair< typename meta::diff_type_t< ForwardIt >, typename meta::value_type_t< ForwardIt >>
Computes the peak value of the range [first, last)
Definition: peak.hpp:38
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr auto peakabs(ForwardIt first, ForwardIt last) -> std::pair< typename meta::diff_type_t< ForwardIt >, typename meta::value_type_t< ForwardIt >>
Computes the absolute peak value of the range [first, last)
Definition: peak.hpp:52
Definition: amplifier.hpp:29