oxilean_std/spectral_methods/
complex_traits.rs1use super::types::Complex;
16
17impl std::ops::Add for Complex {
18 type Output = Complex;
19 fn add(self, rhs: Complex) -> Complex {
20 Complex::new(self.re + rhs.re, self.im + rhs.im)
21 }
22}
23
24impl std::ops::Sub for Complex {
25 type Output = Complex;
26 fn sub(self, rhs: Complex) -> Complex {
27 Complex::new(self.re - rhs.re, self.im - rhs.im)
28 }
29}
30
31impl std::ops::Mul for Complex {
32 type Output = Complex;
33 fn mul(self, rhs: Complex) -> Complex {
34 Complex::new(
35 self.re * rhs.re - self.im * rhs.im,
36 self.re * rhs.im + self.im * rhs.re,
37 )
38 }
39}
40
41impl std::ops::Mul<f64> for Complex {
42 type Output = Complex;
43 fn mul(self, s: f64) -> Complex {
44 Complex::new(self.re * s, self.im * s)
45 }
46}
47
48impl std::ops::Div<f64> for Complex {
49 type Output = Complex;
50 fn div(self, s: f64) -> Complex {
51 Complex::new(self.re / s, self.im / s)
52 }
53}