src/direct_product.rs

branch
dev
changeset 79
d63e40672dd6
parent 60
848ecc05becf
equal deleted inserted replaced
78:cebedc4a8331 79:d63e40672dd6
277 fn dist2_squared(&self, Pair(ref u, ref v) : &Self) -> F { 277 fn dist2_squared(&self, Pair(ref u, ref v) : &Self) -> F {
278 self.0.dist2_squared(u) + self.1.dist2_squared(v) 278 self.0.dist2_squared(u) + self.1.dist2_squared(v)
279 } 279 }
280 } 280 }
281 281
282 impl<F, A, B, U, V> AXPY<F, Pair<U, V>> for Pair<A, B> 282 impl<F, A, B> AXPY for Pair<A, B>
283 where 283 where
284 U : Space, 284 A : AXPY<Field=F>,
285 V : Space, 285 B : AXPY<Field=F>,
286 A : AXPY<F, U>, 286 F : Num + AXPY
287 B : AXPY<F, V>, 287 {
288 F : Num 288 type Field = F;
289 { 289
290 290 fn axpy<I : Instance<Pair<A,B>>>(&mut self, α : F, x : I, β : F) {
291 fn axpy<I : Instance<Pair<U,V>>>(&mut self, α : F, x : I, β : F) {
292 let Pair(u, v) = x.decompose(); 291 let Pair(u, v) = x.decompose();
293 self.0.axpy(α, u, β); 292 self.0.axpy(α, u, β);
294 self.1.axpy(α, v, β); 293 self.1.axpy(α, v, β);
295 } 294 }
296 295
297 fn copy_from<I : Instance<Pair<U,V>>>(&mut self, x : I) { 296 fn copy_from<I : Instance<Pair<A,B>>>(&mut self, x : I) {
298 let Pair(u, v) = x.decompose(); 297 let Pair(u, v) = x.decompose();
299 self.0.copy_from(u); 298 self.0.copy_from(u);
300 self.1.copy_from(v); 299 self.1.copy_from(v);
301 } 300 }
302 301
303 fn scale_from<I : Instance<Pair<U,V>>>(&mut self, α : F, x : I) { 302 fn scale_from<I : Instance<Pair<A,B>>>(&mut self, α : F, x : I) {
304 let Pair(u, v) = x.decompose(); 303 let Pair(u, v) = x.decompose();
305 self.0.scale_from(α, u); 304 self.0.scale_from(α, u);
306 self.1.scale_from(α, v); 305 self.1.scale_from(α, v);
307 } 306 }
308 } 307 }

mercurial