22 #ifndef EDSP_BARTLETT_HPP 23 #define EDSP_BARTLETT_HPP 26 #include <edsp/meta/iterator.hpp> 28 namespace edsp {
namespace windowing {
35 template <
typename OutputIt>
36 constexpr
void bartlett(OutputIt first, OutputIt last) {
37 using value_type = meta::value_type_t<OutputIt>;
38 using size_type = meta::diff_type_t<OutputIt>;
39 const auto size =
static_cast<size_type
>(
std::distance(first, last));
40 const auto middle =
math::is_even(size) ? size / 2 : (size + 1) / 2;
41 const auto factor =
math::inv(static_cast<value_type>(size - 1));
42 for (size_type i = 0; i < middle; ++i, ++first) {
43 *first = 2 * i * factor;
45 for (size_type i = middle; i < size; ++i, ++first) {
46 *first = 2 - 2 * i * factor;
52 #endif // EDSP_BARTLETT_HPP constexpr bool is_even(T x)
Determines if the number is even.
Definition: numeric.hpp:59
constexpr T inv(T x)
Computes the inverse value of the input number.
Definition: numeric.hpp:208
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr void bartlett(OutputIt first, OutputIt last)
Computes a Bartlett window of length N and stores the result in the range, beginning at d_first...
Definition: bartlett.hpp:36
Definition: amplifier.hpp:29