use super::Complex;
use crate::traits::NumericElement;
impl<T: NumericElement> Complex<T> {
pub const ZERO: Self = Self {
re: <T as NumericElement>::ZERO,
im: <T as NumericElement>::ZERO,
};
pub const ONE: Self = Self {
re: <T as NumericElement>::ONE,
im: <T as NumericElement>::ZERO,
};
}
#[cfg(test)]
mod tests {
use super::Complex;
#[test]
fn identity_constants() {
assert_eq!(Complex::<f64>::ZERO, Complex::new(0.0, 0.0));
assert_eq!(Complex::<f32>::ONE, Complex::new(1.0, 0.0));
let z = Complex::new(3.0_f64, -2.0);
assert_eq!(z + Complex::ZERO, z);
assert_eq!(z * Complex::ONE, z);
}
}