440 } |
440 } |
441 } |
441 } |
442 |
442 |
443 impl<F : Float,const N : usize> Euclidean<F> for Loc<F, N> { |
443 impl<F : Float,const N : usize> Euclidean<F> for Loc<F, N> { |
444 type Output = Self; |
444 type Output = Self; |
445 |
|
446 #[inline] |
|
447 fn similar_origin(&self) -> Self { |
|
448 Self::ORIGIN |
|
449 } |
|
450 |
445 |
451 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
446 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
452 /// Use [`nalgebra`] for larger vectors. |
447 /// Use [`nalgebra`] for larger vectors. |
453 #[inline] |
448 #[inline] |
454 fn norm2_squared(&self) -> F { |
449 fn norm2_squared(&self) -> F { |
710 } |
705 } |
711 |
706 |
712 impl<F : Num, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { } |
707 impl<F : Num, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { } |
713 |
708 |
714 impl<F : Num, const N : usize> AXPY<F, Loc<F, N>> for Loc<F, N> { |
709 impl<F : Num, const N : usize> AXPY<F, Loc<F, N>> for Loc<F, N> { |
|
710 type Owned = Self; |
|
711 |
715 #[inline] |
712 #[inline] |
716 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
713 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
717 x.eval(|x̃| { |
714 x.eval(|x̃| { |
718 if β == F::ZERO { |
715 if β == F::ZERO { |
719 map2_mut(self, x̃, |yi, xi| { *yi = α * (*xi) }) |
716 map2_mut(self, x̃, |yi, xi| { *yi = α * (*xi) }) |
725 |
722 |
726 #[inline] |
723 #[inline] |
727 fn copy_from<I : Instance<Loc<F, N>>>(&mut self, x : I) { |
724 fn copy_from<I : Instance<Loc<F, N>>>(&mut self, x : I) { |
728 x.eval(|x̃| map2_mut(self, x̃, |yi, xi| *yi = *xi )) |
725 x.eval(|x̃| map2_mut(self, x̃, |yi, xi| *yi = *xi )) |
729 } |
726 } |
730 } |
727 |
|
728 #[inline] |
|
729 fn similar_origin(&self) -> Self::Owned { |
|
730 Self::ORIGIN |
|
731 } |
|
732 |
|
733 #[inline] |
|
734 fn set_zero(&mut self) { |
|
735 *self = Self::ORIGIN; |
|
736 } |
|
737 } |
|
738 |