mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 06:49:24 -05:00
Extract some constexpr math utilities to utility.hpp
...my dumping ground for so many random bits.
This commit is contained in:
parent
096e961c67
commit
dfbcf5bc75
@ -32,6 +32,7 @@
|
||||
#include "dsp_types.hpp"
|
||||
#include "complex.hpp"
|
||||
#include "hal.h"
|
||||
#include "utility.hpp"
|
||||
|
||||
namespace std {
|
||||
/* https://github.com/AE9RB/fftbench/blob/master/cxlr.hpp
|
||||
@ -47,14 +48,6 @@ namespace std {
|
||||
}
|
||||
} /* namespace std */
|
||||
|
||||
constexpr bool power_of_two(const size_t n) {
|
||||
return (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
constexpr size_t log_2(const size_t n, const size_t p = 0) {
|
||||
return (n <= 1) ? p : log_2(n / 2, p + 1);
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
void fft_swap(const buffer_c16_t src, std::array<T, N>& dst) {
|
||||
static_assert(power_of_two(N), "only defined for N == power of two");
|
||||
|
@ -61,6 +61,14 @@ inline constexpr T pow(const T base, unsigned const exponent) {
|
||||
return (exponent == 0) ? 1 : (base * pow(base, exponent - 1));
|
||||
}
|
||||
|
||||
constexpr bool power_of_two(const size_t n) {
|
||||
return (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
constexpr size_t log_2(const size_t n, const size_t p = 0) {
|
||||
return (n <= 1) ? p : log_2(n / 2, p + 1);
|
||||
}
|
||||
|
||||
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared);
|
||||
|
||||
inline float magnitude_squared(const std::complex<float> c) {
|
||||
|
Loading…
Reference in New Issue
Block a user