pounder_test/dsp/src/lib.rs

43 lines
702 B
Rust
Raw Normal View History

2020-12-04 02:09:54 +08:00
#![cfg_attr(not(test), no_std)]
#![cfg_attr(feature = "nightly", feature(asm, core_intrinsics))]
2020-11-22 23:45:32 +08:00
2020-12-17 08:01:50 +08:00
use core::ops::Neg;
pub type Complex<T> = (T, T);
2020-12-08 02:22:09 +08:00
/// Round up half.
///
/// # Arguments
///
/// `x` - Value to shift and round.
/// `shift` - Number of bits to right shift `x`.
///
/// # Returns
///
/// Shifted and rounded value.
#[inline(always)]
pub fn shift_round(x: i32, shift: usize) -> i32 {
2020-12-08 02:22:09 +08:00
(x + (1 << (shift - 1))) >> shift
}
2020-12-17 08:01:50 +08:00
fn abs<T>(x: T) -> T
where
T: PartialOrd + Default + Neg<Output = T>,
{
if x >= T::default() {
x
} else {
-x
}
}
2020-12-17 07:25:31 +08:00
pub mod atan2;
pub mod cossin;
2020-11-22 23:45:32 +08:00
pub mod iir;
2020-11-23 06:34:38 +08:00
pub mod lockin;
2020-12-04 02:09:54 +08:00
pub mod pll;
2020-12-05 16:56:41 +08:00
pub mod unwrap;
#[cfg(test)]
2020-12-05 18:44:09 +08:00
mod testing;