23 #ifndef EDSP_AMPLIFIER_HPP 24 #define EDSP_AMPLIFIER_HPP 26 #include <edsp/meta/iterator.hpp> 29 namespace edsp {
inline namespace algorithm {
45 template <
typename InputIt,
typename OutputIt,
typename Numeric>
46 constexpr
void amplifier(InputIt first, InputIt last, OutputIt d_first, Numeric factor) {
49 [=](
const meta::value_type_t<InputIt> val) -> meta::value_type_t<OutputIt> {
return factor * val; });
71 template <
typename InputIt,
typename OutputIt,
typename Numeric>
72 constexpr
void amplifier(InputIt first, InputIt last, OutputIt d_first, Numeric factor, Numeric
min, Numeric
max) {
73 std::transform(first, last, d_first,
74 [=](
const meta::value_type_t<InputIt> val) -> meta::value_type_t<OutputIt> {
75 const auto scaled = factor * val;
76 return (scaled < min) ? min : (scaled > max) ? max : scaled;
82 #endif // EDSP_AMPLIFIER_HPP constexpr meta::value_type_t< ForwardIt > max(ForwardIt first, ForwardIt last)
Computes the maximum value of the range [first, last)
Definition: max.hpp:38
constexpr void amplifier(InputIt first, InputIt last, OutputIt d_first, Numeric factor)
Amplifies or attenuates the elements in the range [first, last) and stores the result in another rang...
Definition: amplifier.hpp:46
constexpr meta::value_type_t< ForwardIt > min(ForwardIt first, ForwardIt last)
Computes the minimum value of the range [first, last)
Definition: min.hpp:38
Definition: amplifier.hpp:29