Skip to content

Commit 24555e1

Browse files
committed
Add Conjugate trait
1 parent 2fba371 commit 24555e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/types.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
pub use num_complex::Complex32 as c32;
33
pub use num_complex::Complex64 as c64;
4+
use num_complex::Complex;
45
use num_traits::Float;
56
use std::ops::*;
67

@@ -20,6 +21,10 @@ pub trait Absolute {
2021
}
2122
}
2223

24+
pub trait Conjugate: Copy {
25+
fn conj(self) -> Self;
26+
}
27+
2328
macro_rules! impl_traits {
2429
($real:ty, $complex:ty) => {
2530

@@ -59,6 +64,18 @@ impl Absolute for $complex {
5964
}
6065
}
6166

67+
impl Conjugate for $real {
68+
fn conj(self) -> Self {
69+
self
70+
}
71+
}
72+
73+
impl Conjugate for $complex {
74+
fn conj(self) -> Self {
75+
Complex::conj(&self)
76+
}
77+
}
78+
6279
}} // impl_traits!
6380

6481
impl_traits!(f64, c64);

0 commit comments

Comments
 (0)