#![allow(dead_code)] #![allow(unused_imports)] mod common; use wmath::*; #[test] fn test_complex() { macro_rules! test { ($expr:expr) => { println!("-----[{}]-----", stringify!($expr)); print_expr!($expr, $expr.norm(), $expr.radian()); print_expr!($expr.latex(), $expr.neg(), $expr.rec()); print_expr!($expr.pow(2), $expr.powf(-0.4), $expr.powc(2.1, -1.5)); print_expr!($expr + $expr.neg(), $expr * $expr.rec()); print_expr!($expr / $expr, $expr / Complex::new(0.0, 0.0), ($expr / $expr.rec()).similar(&$expr.pow(2), 1e-8)); }; ($expr:expr, $($exprs:expr),+) => { test!($expr); test!($($exprs),+); } } /* Complex::new */ let com1 = Complex::new(0.0, 0.0); let com2 = Complex::new(9.4, 0.0); let com3 = Complex::new(5.0, 9.2); let com4 = Complex::new(0.0, 0.8); let com5 = Complex::new(-9.3, 8.3); let com6 = Complex::new(-7.0, 0.0); let com7 = Complex::new(-9.2, -0.5); let com8 = Complex::new(0.0, -3.4); let com9 = Complex::new(8.3, -9.2); test!(com1, com2, com3, com4, com5, com6, com7, com8, com9); } fn main() {}