mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-02 03:26:40 -04:00
Extract magnitude_squared to utility.
This commit is contained in:
parent
de0c884b67
commit
76df4f0369
2 changed files with 9 additions and 9 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <complex>
|
||||
#include <memory>
|
||||
|
||||
#include <hal.h>
|
||||
|
@ -67,6 +68,14 @@ static inline void clear_m4_flag_saturation() {
|
|||
|
||||
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared);
|
||||
|
||||
inline float magnitude_squared(const std::complex<float> c) {
|
||||
const auto r = c.real();
|
||||
const auto r2 = r * r;
|
||||
const auto i = c.imag();
|
||||
const auto i2 = i * i;
|
||||
return r2 + i2;
|
||||
}
|
||||
|
||||
/* Override new/delete to use Chibi/OS heap functions */
|
||||
/* NOTE: Do not inline these, it doesn't work. ;-) */
|
||||
void* operator new(size_t size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue