707 fn apply<I : Instance<Loc<F, N>>>(&self, x : I) -> Self::Codomain { |
707 fn apply<I : Instance<Loc<F, N>>>(&self, x : I) -> Self::Codomain { |
708 x.eval(|x̃| self.dot(x̃)) |
708 x.eval(|x̃| self.dot(x̃)) |
709 } |
709 } |
710 } |
710 } |
711 |
711 |
712 impl<F : Num, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { } |
712 impl<F : Num + AXPY, const N : usize> Linear<Loc<F, N>> for Loc<F, N> { |
713 |
713 type LinCodomain = F; |
714 impl<F : Num, const N : usize> AXPY<F, Loc<F, N>> for Loc<F, N> { |
714 } |
|
715 |
|
716 impl<F : Num + AXPY, const N : usize> AXPY for Loc<F, N> { |
|
717 type Field = F; |
715 #[inline] |
718 #[inline] |
716 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
719 fn axpy<I : Instance<Loc<F, N>>>(&mut self, α : F, x : I, β : F) { |
717 x.eval(|x̃| { |
720 x.eval(|x̃| { |
718 if β == F::ZERO { |
721 if β == F::ZERO { |
719 map2_mut(self, x̃, |yi, xi| { *yi = α * (*xi) }) |
722 map2_mut(self, x̃, |yi, xi| { *yi = α * (*xi) }) |