From fea812469ad0a2099e100a4f232b121f5adeec79 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 15 Sep 2024 18:11:56 +0200 Subject: complex! macro --- libmu/src/maths/complex.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libmu/src') diff --git a/libmu/src/maths/complex.rs b/libmu/src/maths/complex.rs index 931b030..ccae000 100644 --- a/libmu/src/maths/complex.rs +++ b/libmu/src/maths/complex.rs @@ -1,6 +1,13 @@ use crate::numeric_types::Float; use core::{fmt, ops}; +#[macro_export] +macro_rules! complex { + ($real:expr, $imaginary:expr) => { + $crate::Complex::new($real, $imaginary) + }; +} + #[derive(Copy, Clone, PartialOrd, PartialEq)] pub struct Complex { pub real: T, @@ -29,7 +36,10 @@ impl Complex { } pub fn get_conjugate(&self) -> Complex { - Complex::new(self.real, -self.imaginary) + Complex { + real: self.real, + imaginary: -self.imaginary, + } } pub fn conjugate(&mut self) { -- cgit v1.3