diff options
Diffstat (limited to 'libmu/src/maths/complex.rs')
| -rw-r--r-- | libmu/src/maths/complex.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libmu/src/maths/complex.rs b/libmu/src/maths/complex.rs index 79212b6..931b030 100644 --- a/libmu/src/maths/complex.rs +++ b/libmu/src/maths/complex.rs @@ -1,7 +1,7 @@ use crate::numeric_types::Float; use core::{fmt, ops}; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialOrd, PartialEq)] pub struct Complex<T: Float> { pub real: T, pub imaginary: T, @@ -49,6 +49,17 @@ impl<T: Float> Complex<T> { } } +impl<T: Float> ops::Neg for Complex<T> { + type Output = Complex<T>; + + fn neg(self) -> Complex<T> { + Complex { + real: -self.real, + imaginary: -self.imaginary, + } + } +} + impl<T: Float> ops::Add for Complex<T> { type Output = Complex<T>; |
