aboutsummaryrefslogtreecommitdiff
path: root/libmu
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2024-09-15 18:11:56 +0200
committerhachem <im@hachem.wtf>2024-09-15 18:11:56 +0200
commitfea812469ad0a2099e100a4f232b121f5adeec79 (patch)
tree1745b02eb369f83ed9d1a71bfadeb7a6bb7003b4 /libmu
parent534445b244759df3f9ffc5ecb2f2ef135de40459 (diff)
complex! macro
Diffstat (limited to 'libmu')
-rw-r--r--libmu/src/maths/complex.rs12
1 files changed, 11 insertions, 1 deletions
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<T: Float> {
pub real: T,
@@ -29,7 +36,10 @@ impl<T: Float> Complex<T> {
}
pub fn get_conjugate(&self) -> Complex<T> {
- Complex::new(self.real, -self.imaginary)
+ Complex {
+ real: self.real,
+ imaginary: -self.imaginary,
+ }
}
pub fn conjugate(&mut self) {