Skip to content
Snippets Groups Projects
Commit 6911c1eb authored by Stephen D's avatar Stephen D
Browse files

add mag_squared

parent da3f2c1c
No related branches found
No related tags found
No related merge requests found
Pipeline #245 passed
[package]
edition = "2021"
name = "goertzel-nostd"
version = "0.1.0"
version = "0.2.0"
authors = ["Stephen D"]
repository = "https://github.com/mcpherrinm/goertzel.git"
keywords = ["dsp", "goertzel", "fft", "fourier"]
......
......@@ -49,6 +49,10 @@ impl Parameters {
pub fn mag(self, samples: &[f32]) -> f32 {
self.start().add_samples(samples).finish_mag()
}
pub fn mag_squared(self, samples: &[f32]) -> f32 {
self.start().add_samples(samples).finish_mag_squared()
}
}
impl Partial {
......@@ -69,8 +73,12 @@ impl Partial {
}
pub fn finish_mag(self) -> f32 {
libm::sqrtf(self.finish_mag_squared())
}
pub fn finish_mag_squared(self) -> f32 {
let (real, imag) = self.finish();
libm::sqrtf(real * real + imag * imag)
real * real + imag * imag
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment