src/nalgebra_support.rs

branch
dev
changeset 133
2b13f8a0c8ba
parent 132
89371dc4d637
child 136
22fd33834ab7
child 138
593912dc3293
equal deleted inserted replaced
132:89371dc4d637 133:2b13f8a0c8ba
222 E: Float + Scalar + Zero + One + RealField, 222 E: Float + Scalar + Zero + One + RealField,
223 DefaultAllocator: Allocator<M>, 223 DefaultAllocator: Allocator<M>,
224 { 224 {
225 #[inline] 225 #[inline]
226 fn dot<I: Instance<Self>>(&self, other: I) -> E { 226 fn dot<I: Instance<Self>>(&self, other: I) -> E {
227 Vector::<E, M, S>::dot(self, other.ref_instance()) 227 other.eval_ref_decompose(|r| Vector::<E, M, S>::dot(self, r))
228 } 228 }
229 229
230 #[inline] 230 #[inline]
231 fn norm2_squared(&self) -> E { 231 fn norm2_squared(&self) -> E {
232 Vector::<E, M, S>::norm_squared(self) 232 Vector::<E, M, S>::norm_squared(self)
233 } 233 }
234 234
235 #[inline] 235 #[inline]
236 fn dist2_squared<I: Instance<Self>>(&self, other: I) -> E { 236 fn dist2_squared<I: Instance<Self>>(&self, other: I) -> E {
237 metric_distance_squared(self, other.ref_instance()) 237 other.eval_ref_decompose(|r| metric_distance_squared(self, r))
238 } 238 }
239 } 239 }
240 240
241 impl<E, M, S> StaticEuclidean<E> for Vector<E, M, S> 241 impl<E, M, S> StaticEuclidean<E> for Vector<E, M, S>
242 where 242 where
303 E: Float + Scalar + Zero + One + RealField, 303 E: Float + Scalar + Zero + One + RealField,
304 DefaultAllocator: Allocator<M>, 304 DefaultAllocator: Allocator<M>,
305 { 305 {
306 #[inline] 306 #[inline]
307 fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> E { 307 fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> E {
308 nalgebra::Norm::metric_distance(&LpNorm(1), self, other.ref_instance()) 308 other.eval_ref_decompose(|r| nalgebra::Norm::metric_distance(&LpNorm(1), self, r))
309 } 309 }
310 } 310 }
311 311
312 impl<E, M, S> Norm<L2, E> for Vector<E, M, S> 312 impl<E, M, S> Norm<L2, E> for Vector<E, M, S>
313 where 313 where
329 E: Float + Scalar + Zero + One + RealField, 329 E: Float + Scalar + Zero + One + RealField,
330 DefaultAllocator: Allocator<M>, 330 DefaultAllocator: Allocator<M>,
331 { 331 {
332 #[inline] 332 #[inline]
333 fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> E { 333 fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> E {
334 nalgebra::Norm::metric_distance(&LpNorm(2), self, other.ref_instance()) 334 other.eval_ref_decompose(|r| nalgebra::Norm::metric_distance(&LpNorm(2), self, r))
335 } 335 }
336 } 336 }
337 337
338 impl<E, M, S> Norm<Linfinity, E> for Vector<E, M, S> 338 impl<E, M, S> Norm<Linfinity, E> for Vector<E, M, S>
339 where 339 where
355 E: Float + Scalar + Zero + One + RealField, 355 E: Float + Scalar + Zero + One + RealField,
356 DefaultAllocator: Allocator<M>, 356 DefaultAllocator: Allocator<M>,
357 { 357 {
358 #[inline] 358 #[inline]
359 fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> E { 359 fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> E {
360 nalgebra::Norm::metric_distance(&UniformNorm, self, other.ref_instance()) 360 other.eval_ref_decompose(|r| nalgebra::Norm::metric_distance(&UniformNorm, self, r))
361 } 361 }
362 } 362 }
363 363
364 /// Helper trait to hide the symbols of [`nalgebra::RealField`]. 364 /// Helper trait to hide the symbols of [`nalgebra::RealField`].
365 /// 365 ///

mercurial