From 534445b244759df3f9ffc5ecb2f2ef135de40459 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 15 Sep 2024 18:09:43 +0200 Subject: Make complex a Numeric --- libmu/src/maths/complex.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libmu/src/maths/complex.rs') 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 { pub real: T, pub imaginary: T, @@ -49,6 +49,17 @@ impl Complex { } } +impl ops::Neg for Complex { + type Output = Complex; + + fn neg(self) -> Complex { + Complex { + real: -self.real, + imaginary: -self.imaginary, + } + } +} + impl ops::Add for Complex { type Output = Complex; -- cgit v1.3