| 271 // TODO: should allow different input storages in `Euclidean`. |
271 // TODO: should allow different input storages in `Euclidean`. |
| 272 |
272 |
| 273 impl<E, M, S> Euclidean<E> for Vector<E, M, S> |
273 impl<E, M, S> Euclidean<E> for Vector<E, M, S> |
| 274 where |
274 where |
| 275 M: Dim, |
275 M: Dim, |
| 276 S: StorageMut<E, M> + Clone, |
276 S: Storage<E, M>, |
| 277 E: Float + Scalar + Zero + One + RealField, |
277 E: Float + Scalar + Zero + One + RealField, |
| 278 DefaultAllocator: Allocator<M>, |
278 DefaultAllocator: Allocator<M>, |
| 279 { |
279 { |
| |
280 type OwnedEuclidean = OVector<E, M>; |
| |
281 |
| 280 #[inline] |
282 #[inline] |
| 281 fn dot<I: Instance<Self>>(&self, other: I) -> E { |
283 fn dot<I: Instance<Self>>(&self, other: I) -> E { |
| 282 other.eval_ref_decompose(|r| Vector::<E, M, S>::dot(self, r)) |
284 other.eval_ref_decompose(|r| Vector::<E, M, S>::dot(self, r)) |
| 283 } |
285 } |
| 284 |
286 |
| 294 } |
296 } |
| 295 |
297 |
| 296 impl<E, M, S> StaticEuclidean<E> for Vector<E, M, S> |
298 impl<E, M, S> StaticEuclidean<E> for Vector<E, M, S> |
| 297 where |
299 where |
| 298 M: DimName, |
300 M: DimName, |
| 299 S: StorageMut<E, M> + Clone, |
301 S: Storage<E, M>, |
| 300 E: Float + Scalar + Zero + One + RealField, |
302 E: Float + Scalar + Zero + One + RealField, |
| 301 DefaultAllocator: Allocator<M>, |
303 DefaultAllocator: Allocator<M>, |
| 302 { |
304 { |
| 303 #[inline] |
305 #[inline] |
| 304 fn origin() -> OVector<E, M> { |
306 fn origin() -> OVector<E, M> { |
| 308 |
310 |
| 309 /// The default norm for `Vector` is [`L2`]. |
311 /// The default norm for `Vector` is [`L2`]. |
| 310 impl<E, M, S> Normed<E> for Vector<E, M, S> |
312 impl<E, M, S> Normed<E> for Vector<E, M, S> |
| 311 where |
313 where |
| 312 M: Dim, |
314 M: Dim, |
| 313 S: Storage<E, M> + Clone, |
315 S: Storage<E, M>, |
| 314 E: Float + Scalar + Zero + One + RealField, |
316 E: Float + Scalar + Zero + One + RealField, |
| 315 DefaultAllocator: Allocator<M>, |
317 DefaultAllocator: Allocator<M>, |
| 316 { |
318 { |
| 317 type NormExp = L2; |
319 type NormExp = L2; |
| 318 |
320 |
| 328 } |
330 } |
| 329 |
331 |
| 330 impl<E, M, S> HasDual<E> for Vector<E, M, S> |
332 impl<E, M, S> HasDual<E> for Vector<E, M, S> |
| 331 where |
333 where |
| 332 M: Dim, |
334 M: Dim, |
| 333 S: StorageMut<E, M> + Clone, |
335 S: Storage<E, M>, |
| 334 E: Float + Scalar + Zero + One + RealField, |
336 E: Float + Scalar + Zero + One + RealField, |
| 335 DefaultAllocator: Allocator<M>, |
337 DefaultAllocator: Allocator<M>, |
| 336 { |
338 { |
| 337 // TODO: Doesn't work with different storage formats. |
339 type DualSpace = OVector<E, M>; |
| 338 type DualSpace = Vector<E, M, S>; |
|
| 339 |
340 |
| 340 fn dual_origin(&self) -> OVector<E, M> { |
341 fn dual_origin(&self) -> OVector<E, M> { |
| 341 OVector::zeros_generic(M::from_usize(self.len()), Const) |
342 OVector::zeros_generic(M::from_usize(self.len()), Const) |
| 342 } |
343 } |
| 343 } |
344 } |