src/euclidean/wrap.rs

branch
dev
changeset 175
ef02a80bf4bc
parent 174
53ab61a41d70
child 176
21e51de02ab6
equal deleted inserted replaced
174:53ab61a41d70 175:ef02a80bf4bc
134 $crate::wrap!(impl_binary_mut $type, std::ops::SubAssign, sub_assign where $($qual)*); 134 $crate::wrap!(impl_binary_mut $type, std::ops::SubAssign, sub_assign where $($qual)*);
135 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::MulAssign, mul_assign where $($qual)*); 135 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::MulAssign, mul_assign where $($qual)*);
136 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::DivAssign, div_assign where $($qual)*); 136 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::DivAssign, div_assign where $($qual)*);
137 137
138 $crate::self_ownable!($type where $($qual)*); 138 $crate::self_ownable!($type where $($qual)*);
139
140 impl<$($qual)*> $crate::norms::Norm<$crate::norms::L2, $F> for $type
141 {
142 fn norm(&self, p : $crate::norms::L2) -> $F {
143 self.get_view().norm(p)
144 }
145 }
146
147 impl<$($qual)*> $crate::norms::Dist<$crate::norms::L2, $F> for $type
148 {
149 fn dist<I: $crate::instance::Instance<Self>>(&self, other : I, p : $crate::norms::L2) -> $F {
150 other.eval_decompose(|x| self.get_view().dist(p, x))
151 }
152 }
153
154 impl<$($qual)*> $crate::norms::Normed<$F> for $type {
155 type NormExp = $crate::norms::L2;
156
157 fn norm_exponent(&self) -> Self::NormExp {
158 $crate::norms::L2
159 }
160 }
161
162 impl<$($qual)*> $crate::norms::HasDual<$F> for $type {
163 type DualSpace = Self;
164
165 fn dual_origin(&self) -> Self {
166 self.similar_origin(self)
167 }
168 }
139 169
140 impl<$($qual)*> $crate::euclidean::Euclidean<$F> for $type 170 impl<$($qual)*> $crate::euclidean::Euclidean<$F> for $type
141 // where 171 // where
142 // Self: $crate::euclidean::wrap::Wrapped<WrappedField = $F> 172 // Self: $crate::euclidean::wrap::Wrapped<WrappedField = $F>
143 // + Sized 173 // + Sized
205 }) 235 })
206 } 236 }
207 237
208 fn scale_from<I: $crate::instance::Instance<Self>>(&mut self, α: $F, x: I) { 238 fn scale_from<I: $crate::instance::Instance<Self>>(&mut self, α: $F, x: I) {
209 x.eval_decompose(|v| { 239 x.eval_decompose(|v| {
210 self.get_mut_view().scale_from(α, v.get_view()) 240 self.get_view_mut().scale_from(α, v.get_view())
211 }) 241 })
212 } 242 }
213 243
214 /// Set self to zero. 244 /// Set self to zero.
215 fn set_zero(&mut self) { 245 fn set_zero(&mut self) {
216 self.get_mut_view().set_zero() 246 self.get_view_mut().set_zero()
217 } 247 }
218 } 248 }
219 249
220 impl<$($qual)*> $crate::instance::Space for $type { 250 impl<$($qual)*> $crate::instance::Space for $type {
221 type Decomp = <<Self as $crate::euclidean::wrap::Wrapped>::Unwrapped as $crate::instance::Space>::Decomp; 251 type Decomp = <<Self as $crate::euclidean::wrap::Wrapped>::Unwrapped as $crate::instance::Space>::Decomp;

mercurial