diff --git a/dsp/src/iir.rs b/dsp/src/iir.rs index c6f2100..48c92e9 100644 --- a/dsp/src/iir.rs +++ b/dsp/src/iir.rs @@ -2,23 +2,13 @@ use core::ops::{Add, Mul, Neg}; use serde::{Deserialize, Serialize}; use core::f32; +use super::abs; // These are implemented here because core::f32 doesn't have them (yet). // They are naive and don't handle inf/nan. // `compiler-intrinsics`/llvm should have better (robust, universal, and // faster) implementations. -fn abs(x: T) -> T -where - T: PartialOrd + Default + Neg, -{ - if x >= T::default() { - x - } else { - -x - } -} - fn copysign(x: T, y: T) -> T where T: PartialOrd + Default + Neg, diff --git a/dsp/src/lib.rs b/dsp/src/lib.rs index ef0c131..2fbd121 100644 --- a/dsp/src/lib.rs +++ b/dsp/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(test), no_std)] #![cfg_attr(feature = "nightly", feature(asm, core_intrinsics))] +use core::ops::Neg; + pub type Complex = (T, T); /// Round up half. @@ -18,6 +20,17 @@ pub fn shift_round(x: i32, shift: usize) -> i32 { (x + (1 << (shift - 1))) >> shift } +fn abs(x: T) -> T +where + T: PartialOrd + Default + Neg, +{ + if x >= T::default() { + x + } else { + -x + } +} + pub mod atan2; pub mod cossin; pub mod iir;