427 |
427 |
428 domination!(Linfinity, L1); |
428 domination!(Linfinity, L1); |
429 domination!(Linfinity, L2); |
429 domination!(Linfinity, L2); |
430 domination!(L2, L1); |
430 domination!(L2, L1); |
431 |
431 |
432 impl<F : Num,const N : usize> Dot<Loc<F, N>,F> for Loc<F, N> { |
432 impl<F : Float,const N : usize> Euclidean<F> for Loc<F, N> { |
|
433 type Output = Self; |
|
434 |
433 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
435 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
434 /// Use [`nalgebra`] for larger vectors. |
436 /// Use [`nalgebra`] for larger vectors. |
435 #[inline] |
437 #[inline] |
436 fn dot(&self, other : &Loc<F, N>) -> F { |
438 fn dot<I : Instance<Self>>(&self, other : I) -> F { |
437 self.0.iter() |
439 self.0.iter() |
438 .zip(other.0.iter()) |
440 .zip(other.ref_instance().0.iter()) |
439 .fold(F::ZERO, |m, (&v, &w)| m + v * w) |
441 .fold(F::ZERO, |m, (&v, &w)| m + v * w) |
440 } |
442 } |
441 } |
|
442 |
|
443 impl<F : Float,const N : usize> Euclidean<F> for Loc<F, N> { |
|
444 type Output = Self; |
|
445 |
443 |
446 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
444 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
447 /// Use [`nalgebra`] for larger vectors. |
445 /// Use [`nalgebra`] for larger vectors. |
448 #[inline] |
446 #[inline] |
449 fn norm2_squared(&self) -> F { |
447 fn norm2_squared(&self) -> F { |
694 |
692 |
695 impl<F : Num, const N : usize> Space for Loc<F, N> { |
693 impl<F : Num, const N : usize> Space for Loc<F, N> { |
696 type Decomp = BasicDecomposition; |
694 type Decomp = BasicDecomposition; |
697 } |
695 } |
698 |
696 |
699 impl<F : Num, const N : usize> Mapping<Loc<F, N>> for Loc<F, N> { |
697 impl<F : Float, const N : usize> Mapping<Loc<F, N>> for Loc<F, N> { |
700 type Codomain = F; |
698 type Codomain = F; |
701 |
699 |
702 fn apply<I : Instance<Loc<F, N>>>(&self, x : I) -> Self::Codomain { |
700 fn apply<I : Instance<Loc<F, N>>>(&self, x : I) -> Self::Codomain { |
703 x.eval(|x̃| self.dot(x̃)) |
701 x.eval(|x̃| self.dot(x̃)) |
704 } |
702 } |
705 } |
703 } |
706 |
704 |
707 impl<F : Num, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { } |
705 impl<F : Float, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { } |
708 |
706 |
709 impl<F : Num, const N : usize> AXPY<F, Loc<F, N>> for Loc<F, N> { |
707 impl<F : Float, const N : usize> AXPY<F, Loc<F, N>> for Loc<F, N> { |
710 type Owned = Self; |
708 type Owned = Self; |
711 |
709 |
712 #[inline] |
710 #[inline] |
713 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
711 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
714 x.eval(|x̃| { |
712 x.eval(|x̃| { |