File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
1
2
- use num_complex:: Complex ;
2
+ pub use num_complex:: Complex32 as c32;
3
+ pub use num_complex:: Complex64 as c64;
4
+ use num_traits:: Float ;
5
+ use std:: ops:: * ;
3
6
4
- pub use num_comlex:: Complex32 as c32;
5
- pub use num_comlex:: Complex64 as c64;
7
+ pub trait AssociatedReal : Sized {
8
+ type Real : Float + Mul < Self , Output = Self > ;
9
+ }
10
+ pub trait AssociatedComplex : Sized {
11
+ type Complex ;
12
+ }
13
+
14
+ macro_rules! impl_assoc {
15
+ ( $real: ty, $complex: ty) => {
16
+ impl AssociatedReal for $real {
17
+ type Real = $real;
18
+ }
19
+ impl AssociatedReal for $complex {
20
+ type Real = $real;
21
+ }
22
+ impl AssociatedComplex for $real {
23
+ type Complex = $complex;
24
+ }
25
+ impl AssociatedComplex for $complex {
26
+ type Complex = $complex;
27
+ }
28
+ } } // impl_assoc!
29
+
30
+ impl_assoc ! ( f64 , c64) ;
31
+ impl_assoc ! ( f32 , c32) ;
You can’t perform that action at this time.
0 commit comments