1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use alga::general::Field;
use core::{Scalar, Matrix};
use core::dimension::{Dim, DimName, U1};
use core::storage::StorageMut;
use geometry::PointBase;
pub trait Axpy<A> {
fn axpy(&mut self, a: A, x: &Self);
}
impl<N, R: Dim, C: Dim, S> Axpy<N> for Matrix<N, R, C, S>
where N: Scalar + Field,
S: StorageMut<N, R, C> {
#[inline]
fn axpy(&mut self, a: N, x: &Self) {
for (me, x) in self.iter_mut().zip(x.iter()) {
*me += *x * a;
}
}
}
impl<N, D: DimName, S> Axpy<N> for PointBase<N, D, S>
where N: Scalar + Field,
S: StorageMut<N, D, U1> {
#[inline]
fn axpy(&mut self, a: N, x: &Self) {
for (me, x) in self.coords.iter_mut().zip(x.coords.iter()) {
*me += *x * a;
}
}
}