Skip to main content

oxilean_std/complex/
functions_2.rs

1//! Auto-generated module
2//!
3//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
4
5use std::f64::consts::PI;
6
7use super::types::*;
8
9/// Argument principle: number of zeros minus poles inside contour.
10#[allow(dead_code)]
11pub fn argument_principle_zeros_minus_poles(
12    contour_winding: i32,
13    n_zeros: i32,
14    n_poles: i32,
15) -> bool {
16    contour_winding == n_zeros - n_poles
17}
18#[cfg(test)]
19mod tests_complex_extra {
20    use super::*;
21    #[test]
22    fn test_c64_arithmetic() {
23        let a = C64::new(1.0, 2.0);
24        let b = C64::new(3.0, 4.0);
25        let sum = a.add(&b);
26        assert!((sum.re - 4.0).abs() < 1e-12);
27        assert!((sum.im - 6.0).abs() < 1e-12);
28        let prod = a.mul(&b);
29        assert!((prod.re - (-5.0)).abs() < 1e-12);
30        assert!((prod.im - 10.0).abs() < 1e-12);
31    }
32    #[test]
33    fn test_c64_modulus_argument() {
34        let z = C64::new(1.0, 1.0);
35        assert!((z.modulus() - std::f64::consts::SQRT_2).abs() < 1e-12);
36        assert!((z.argument() - std::f64::consts::PI / 4.0).abs() < 1e-12);
37    }
38    #[test]
39    fn test_c64_exp() {
40        let pi_i = C64::new(0.0, std::f64::consts::PI);
41        let result = pi_i.exp();
42        assert!((result.re + 1.0).abs() < 1e-12);
43        assert!(result.im.abs() < 1e-12);
44    }
45    #[test]
46    fn test_c64_sqrt() {
47        let z = C64::new(-1.0, 0.0);
48        let s = z.sqrt_principal();
49        assert!(s.re.abs() < 1e-12);
50        assert!((s.im - 1.0).abs() < 1e-12);
51    }
52    #[test]
53    fn test_mobius_identity() {
54        let id = MobiusMap::identity();
55        let z = C64::new(2.0, 3.0);
56        let result = id.apply(z).expect("apply should succeed");
57        assert!((result.re - z.re).abs() < 1e-12);
58        assert!((result.im - z.im).abs() < 1e-12);
59    }
60    #[test]
61    fn test_mobius_compose() {
62        let id = MobiusMap::identity();
63        let comp = id.compose(&id);
64        let z = C64::new(1.0, 1.0);
65        let r1 = id.apply(z).expect("apply should succeed");
66        let r2 = comp.apply(z).expect("apply should succeed");
67        assert!((r1.re - r2.re).abs() < 1e-9);
68    }
69    #[test]
70    fn test_conformal_map() {
71        let m = ConformalMap::upper_half_to_disk();
72        assert_eq!(m.source_domain, "UpperHalfPlane");
73        assert!(m.is_biholomorphic());
74    }
75}