16 constexpr
inline long double operator ""dB(
long double arg)
18 return std::pow(10, arg / 20);
21 constexpr
inline long double operator ""_dB(
long double arg)
23 return std::pow(10, arg / 20);
38 static inline T
from(T arg)
40 return std::pow(10, arg / 20);
47 static inline T
to(T arg)
49 return 20 * std::log10(arg);
60 constexpr T pi = static_cast<T>(M_PI);
61 return x ? (size * std::sin(pi * x) * std::sin(pi * x / size)) / (pi * pi * x * x) : 1;
71 constexpr T pi = static_cast<T>(M_PI);
72 return x ? (std::sin(pi * x)) / (pi * x) : 1;
78 template<
typename T,
typename Container>
79 auto to_complex(
const Container& c) -> decltype(std::begin(c), std::end(c), std::vector<std::complex<T>>())
81 return to_complex(c, std::distance(std::begin(c), std::end(c)));
87 template<
typename T,
typename Container>
88 auto to_complex(
const Container& c, std::size_t size) -> decltype(std::begin(c), std::end(c), std::vector<std::complex<T>>())
90 std::vector<std::complex<T>> ret;
93 std::size_t count = 0;
95 for (
auto it = std::begin(c); count < size && it != std::end(c); it++, count++)
97 ret.emplace_back(static_cast<T>(*it));
100 for (; count < size; ++count)
101 ret.emplace_back(T());
103 return std::move(ret);
109 template<
typename T,
typename Container>
110 auto normalize(Container& c, T scale,
double threshold = 1e-8f) -> decltype(std::begin(c), std::end(c),
void())
112 if (scale < threshold)
115 const T normalization = T(1) / std::sqrt(scale);
117 for (
auto it = std::begin(c); it != std::end(c); it++)
118 *it *= normalization;
124 template<
typename Container>
125 auto accumulate_norm(
const Container& c) -> decltype(std::begin(c), std::end(c), std::norm(c[0]))
129 using T = decltype(norm(c[0]));
133 for (
auto it = begin(c); it != end(c); it++)
144 template<
typename T,
typename Container>
145 auto multiply(Container& c, T scale) -> decltype(std::begin(c), std::end(c),
void())
147 for (
auto it = std::begin(c); it != std::end(c); it++)