src/nalgebra_support.rs

branch
dev
changeset 70
672aec2e1acd
parent 64
4f6ca107ccb1
child 82
981069ef919b
equal deleted inserted replaced
69:e5fab0125a8e 70:672aec2e1acd
11 use nalgebra::{ 11 use nalgebra::{
12 Matrix, Storage, StorageMut, OMatrix, Dim, DefaultAllocator, Scalar, 12 Matrix, Storage, StorageMut, OMatrix, Dim, DefaultAllocator, Scalar,
13 ClosedAddAssign, ClosedMulAssign, SimdComplexField, Vector, OVector, RealField, 13 ClosedAddAssign, ClosedMulAssign, SimdComplexField, Vector, OVector, RealField,
14 LpNorm, UniformNorm 14 LpNorm, UniformNorm
15 }; 15 };
16 use nalgebra::Norm as NalgebraNorm;
17 use nalgebra::base::constraint::{ 16 use nalgebra::base::constraint::{
18 ShapeConstraint, SameNumberOfRows, SameNumberOfColumns 17 ShapeConstraint, SameNumberOfRows, SameNumberOfColumns
19 }; 18 };
20 use nalgebra::base::dimension::*; 19 use nalgebra::base::dimension::*;
21 use nalgebra::base::allocator::Allocator; 20 use nalgebra::base::allocator::Allocator;
254 E : Float + Scalar + Zero + One + RealField, 253 E : Float + Scalar + Zero + One + RealField,
255 DefaultAllocator : Allocator<M> { 254 DefaultAllocator : Allocator<M> {
256 255
257 #[inline] 256 #[inline]
258 fn norm(&self, _ : L1) -> E { 257 fn norm(&self, _ : L1) -> E {
259 LpNorm(1).norm(self) 258 nalgebra::Norm::norm(&LpNorm(1), self)
260 } 259 }
261 } 260 }
262 261
263 impl<E,M,S> Dist<E, L1> 262 impl<E,M,S> Dist<E, L1>
264 for Vector<E,M,S> 263 for Vector<E,M,S>
266 S : Storage<E,M> + Clone, 265 S : Storage<E,M> + Clone,
267 E : Float + Scalar + Zero + One + RealField, 266 E : Float + Scalar + Zero + One + RealField,
268 DefaultAllocator : Allocator<M> { 267 DefaultAllocator : Allocator<M> {
269 #[inline] 268 #[inline]
270 fn dist<I : Instance<Self>>(&self, other : I, _ : L1) -> E { 269 fn dist<I : Instance<Self>>(&self, other : I, _ : L1) -> E {
271 LpNorm(1).metric_distance(self, other.ref_instance()) 270 nalgebra::Norm::metric_distance(&LpNorm(1), self, other.ref_instance())
272 } 271 }
273 } 272 }
274 273
275 impl<E,M,S> Norm<E, L2> 274 impl<E,M,S> Norm<E, L2>
276 for Vector<E,M,S> 275 for Vector<E,M,S>
279 E : Float + Scalar + Zero + One + RealField, 278 E : Float + Scalar + Zero + One + RealField,
280 DefaultAllocator : Allocator<M> { 279 DefaultAllocator : Allocator<M> {
281 280
282 #[inline] 281 #[inline]
283 fn norm(&self, _ : L2) -> E { 282 fn norm(&self, _ : L2) -> E {
284 LpNorm(2).norm(self) 283 nalgebra::Norm::norm(&LpNorm(2), self)
285 } 284 }
286 } 285 }
287 286
288 impl<E,M,S> Dist<E, L2> 287 impl<E,M,S> Dist<E, L2>
289 for Vector<E,M,S> 288 for Vector<E,M,S>
291 S : Storage<E,M> + Clone, 290 S : Storage<E,M> + Clone,
292 E : Float + Scalar + Zero + One + RealField, 291 E : Float + Scalar + Zero + One + RealField,
293 DefaultAllocator : Allocator<M> { 292 DefaultAllocator : Allocator<M> {
294 #[inline] 293 #[inline]
295 fn dist<I : Instance<Self>>(&self, other : I, _ : L2) -> E { 294 fn dist<I : Instance<Self>>(&self, other : I, _ : L2) -> E {
296 LpNorm(2).metric_distance(self, other.ref_instance()) 295 nalgebra::Norm::metric_distance(&LpNorm(2), self, other.ref_instance())
297 } 296 }
298 } 297 }
299 298
300 impl<E,M,S> Norm<E, Linfinity> 299 impl<E,M,S> Norm<E, Linfinity>
301 for Vector<E,M,S> 300 for Vector<E,M,S>
304 E : Float + Scalar + Zero + One + RealField, 303 E : Float + Scalar + Zero + One + RealField,
305 DefaultAllocator : Allocator<M> { 304 DefaultAllocator : Allocator<M> {
306 305
307 #[inline] 306 #[inline]
308 fn norm(&self, _ : Linfinity) -> E { 307 fn norm(&self, _ : Linfinity) -> E {
309 UniformNorm.norm(self) 308 nalgebra::Norm::norm(&UniformNorm, self)
310 } 309 }
311 } 310 }
312 311
313 impl<E,M,S> Dist<E, Linfinity> 312 impl<E,M,S> Dist<E, Linfinity>
314 for Vector<E,M,S> 313 for Vector<E,M,S>
316 S : Storage<E,M> + Clone, 315 S : Storage<E,M> + Clone,
317 E : Float + Scalar + Zero + One + RealField, 316 E : Float + Scalar + Zero + One + RealField,
318 DefaultAllocator : Allocator<M> { 317 DefaultAllocator : Allocator<M> {
319 #[inline] 318 #[inline]
320 fn dist<I : Instance<Self>>(&self, other : I, _ : Linfinity) -> E { 319 fn dist<I : Instance<Self>>(&self, other : I, _ : Linfinity) -> E {
321 UniformNorm.metric_distance(self, other.ref_instance()) 320 nalgebra::Norm::metric_distance(&UniformNorm, self, other.ref_instance())
322 } 321 }
323 } 322 }
324 323
325 /// Helper trait to hide the symbols of [`nalgebra::RealField`]. 324 /// Helper trait to hide the symbols of [`nalgebra::RealField`].
326 /// 325 ///

mercurial