src/loc.rs

branch
dev
changeset 145
0b9aecd7bb76
parent 138
593912dc3293
child 150
c4e394a9c84c
equal deleted inserted replaced
144:44d859269132 145:0b9aecd7bb76
606 fn norm(&self, _: L2) -> F { 606 fn norm(&self, _: L2) -> F {
607 self.norm2() 607 self.norm2()
608 } 608 }
609 } 609 }
610 610
611 impl<F: Float, const N: usize> Dist<F, L2> for Loc<N, F> { 611 impl<F: Float, const N: usize> Dist<L2, F> for Loc<N, F> {
612 #[inline] 612 #[inline]
613 fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> F { 613 fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> F {
614 self.dist2(other) 614 self.dist2(other)
615 } 615 }
616 } 616 }
633 fn norm(&self, _: L1) -> F { 633 fn norm(&self, _: L1) -> F {
634 self.iter().fold(F::ZERO, |m, v| m + v.abs()) 634 self.iter().fold(F::ZERO, |m, v| m + v.abs())
635 } 635 }
636 } 636 }
637 637
638 impl<F: Float, const N: usize> Dist<F, L1> for Loc<N, F> { 638 impl<F: Float, const N: usize> Dist<L1, F> for Loc<N, F> {
639 #[inline] 639 #[inline]
640 fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> F { 640 fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> F {
641 other.eval_ref_decompose(|r| { 641 other.eval_ref_decompose(|r| {
642 self.iter() 642 self.iter()
643 .zip(r.iter()) 643 .zip(r.iter())
661 fn norm(&self, _: Linfinity) -> F { 661 fn norm(&self, _: Linfinity) -> F {
662 self.iter().fold(F::ZERO, |m, v| m.max(v.abs())) 662 self.iter().fold(F::ZERO, |m, v| m.max(v.abs()))
663 } 663 }
664 } 664 }
665 665
666 impl<F: Float, const N: usize> Dist<F, Linfinity> for Loc<N, F> { 666 impl<F: Float, const N: usize> Dist<Linfinity, F> for Loc<N, F> {
667 #[inline] 667 #[inline]
668 fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> F { 668 fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> F {
669 other.eval_ref_decompose(|r| { 669 other.eval_ref_decompose(|r| {
670 self.iter() 670 self.iter()
671 .zip(r.iter()) 671 .zip(r.iter())

mercurial