1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#![doc="Support for algebraic structure traits on complex numbers.
"]
use num::complex::Complex;
use num::traits::{Float};
use std::fmt::Debug;
use algebra::ops::Division;
use algebra::structure::semigroup::{SemiGroupAddPartial,
SemiGroupMulPartial};
use algebra::structure::quasigroup::{QuasiGroupAddPartial};
use algebra::structure::monoid::{CommutativeMonoidAddPartial
, CommutativeMonoidMulPartial};
use algebra::structure::group::{CommutativeGroupAddPartial};
use algebra::structure::integral_domain::{IntegralDomainPartial};
use algebra::structure::field::{FieldPartial};
use algebra::ops::Recip;
impl <T : Float> Division for Complex<T> {
}
impl<T: Float> Recip for Complex<T> {
type Output = Self;
#[inline]
fn recip(self) -> Complex<T>{
self.inv()
}
}
impl <T: Float + Debug> SemiGroupAddPartial for Complex<T> {
}
impl <T: Float + Debug> SemiGroupMulPartial for Complex<T> {
}
impl <T: Float + Debug> CommutativeMonoidAddPartial for Complex<T> {
}
impl <T: Float + Debug> CommutativeMonoidMulPartial for Complex<T> {
}
impl <T: Float + Debug> QuasiGroupAddPartial for Complex<T> {
}
impl <T: Float + Debug> CommutativeGroupAddPartial for Complex<T> {
}
impl <T: Float + Debug> IntegralDomainPartial for Complex<T> {
}
impl <T: Float + Debug> FieldPartial for Complex<T> {
}
#[cfg(test)]
mod tests {
use num::complex::{Complex, Complex32};
use algebra::structure::*;
#[test]
fn test_complex_traits() {
let c : Complex32 = Complex { re: 0.0, im: 0.0 };
is_magma_base(&c);
is_magma_add_partial(&c);
is_magma_mul_partial(&c);
is_quasigroup_add_partial(&c);
is_semigroup_add_partial(&c);
is_semigroup_mul_partial(&c);
is_loop_add_partial(&c);
is_monoid_add_partial(&c);
is_monoid_mul_partial(&c);
is_group_add_partial(&c);
is_commutative_group_add_partial(&c);
is_ring_partial(&c);
is_commutative_ring_partial(&c);
is_integral_domain_partial(&c);
is_field_partial(&c);
}
}