oxilean_std/complex/
complex_traits.rs1use super::complex_type::Complex;
16use std::fmt;
17
18impl std::fmt::Display for Complex {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 if self.im >= 0.0 {
21 write!(f, "{} + {}i", self.re, self.im)
22 } else {
23 write!(f, "{} - {}i", self.re, -self.im)
24 }
25 }
26}
27
28impl std::ops::Add for Complex {
29 type Output = Self;
30 fn add(self, other: Self) -> Self {
31 Self::add(self, other)
32 }
33}
34
35impl std::ops::Sub for Complex {
36 type Output = Self;
37 fn sub(self, other: Self) -> Self {
38 Self::sub(self, other)
39 }
40}
41
42impl std::ops::Mul for Complex {
43 type Output = Self;
44 fn mul(self, other: Self) -> Self {
45 Self::mul(self, other)
46 }
47}
48
49impl std::ops::Neg for Complex {
50 type Output = Self;
51 fn neg(self) -> Self {
52 Self::neg(self)
53 }
54}