mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-05-27 10:47:10 -04: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
2 changed files with 9 additions and 8 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue