2020-12-04 02:09:54 +08:00
|
|
|
#![cfg_attr(not(test), no_std)]
|
2020-11-27 17:36:30 +08:00
|
|
|
#![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;
|
|
|
|
|
2020-11-29 08:21:08 +08:00
|
|
|
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.
|
2020-12-10 23:56:13 +08:00
|
|
|
#[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-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-17 08:26:44 +08:00
|
|
|
pub mod trig;
|
2020-12-05 16:56:41 +08:00
|
|
|
pub mod unwrap;
|
2020-11-29 08:41:16 +08:00
|
|
|
|
|
|
|
#[cfg(test)]
|
2020-12-05 18:44:09 +08:00
|
|
|
mod testing;
|