576 fn origin() -> Self { |
576 fn origin() -> Self { |
577 Self::ORIGIN |
577 Self::ORIGIN |
578 } |
578 } |
579 } |
579 } |
580 |
580 |
|
581 |
|
582 /// The default norm for `Loc` is [`L2`]. |
|
583 impl<F : Float, const N : usize> Normed<F> for Loc<F, N> { |
|
584 type NormExp = L2; |
|
585 |
|
586 #[inline] |
|
587 fn norm_exponent(&self) -> Self::NormExp { |
|
588 L2 |
|
589 } |
|
590 |
|
591 // #[inline] |
|
592 // fn similar_origin(&self) -> Self { |
|
593 // [F::ZERO; N].into() |
|
594 // } |
|
595 |
|
596 #[inline] |
|
597 fn is_zero(&self) -> bool { |
|
598 self.norm2_squared() == F::ZERO |
|
599 } |
|
600 } |
|
601 |
|
602 impl<F : Float, const N : usize> HasDual<F> for Loc<F, N> { |
|
603 type DualSpace = Self; |
|
604 } |
|
605 |
581 impl<F : Float, const N : usize> Norm<F, L2> for Loc<F, N> { |
606 impl<F : Float, const N : usize> Norm<F, L2> for Loc<F, N> { |
582 #[inline] |
607 #[inline] |
583 fn norm(&self, _ : L2) -> F { self.norm2() } |
608 fn norm(&self, _ : L2) -> F { self.norm2() } |
584 } |
609 } |
585 |
610 |
586 impl<F : Float, const N : usize> Dist<F, L2> for Loc<F, N> { |
611 impl<F : Float, const N : usize> Dist<F, L2> for Loc<F, N> { |
587 #[inline] |
612 #[inline] |
588 fn dist(&self, other : &Self, _ : L2) -> F { self.dist2(other) } |
613 fn dist(&self, other : &Self, _ : L2) -> F { self.dist2(other) } |
589 } |
614 } |
|
615 |
|
616 /* Implemented automatically as Euclidean. |
|
617 impl<F : Float, const N : usize> Projection<F, L2> for Loc<F, N> { |
|
618 #[inline] |
|
619 fn proj_ball_mut(&mut self, ρ : F, nrm : L2) { |
|
620 let n = self.norm(nrm); |
|
621 if n > ρ { |
|
622 *self *= ρ/n; |
|
623 } |
|
624 } |
|
625 }*/ |
590 |
626 |
591 impl<F : Float, const N : usize> Norm<F, L1> for Loc<F, N> { |
627 impl<F : Float, const N : usize> Norm<F, L1> for Loc<F, N> { |
592 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
628 /// This implementation is not stabilised as it's meant to be used for very small vectors. |
593 /// Use [`nalgebra`] for larger vectors. |
629 /// Use [`nalgebra`] for larger vectors. |
594 #[inline] |
630 #[inline] |