61 DefaultAllocator : Allocator<M,K>, |
61 DefaultAllocator : Allocator<M,K>, |
62 DefaultAllocator : Allocator<N,M>, |
62 DefaultAllocator : Allocator<N,M>, |
63 DefaultAllocator : Allocator<M,N> { |
63 DefaultAllocator : Allocator<M,N> { |
64 } |
64 } |
65 |
65 |
66 impl<SM,SV1,SV2,N,M,K,E> GEMV<E, Matrix<E,M,K,SV1>, Matrix<E,N,K,SV2>> for Matrix<E,N,M,SM> |
66 impl<SM,SV1,N,M,K,E> GEMV<E, Matrix<E,M,K,SV1>> for Matrix<E,N,M,SM> |
67 where SM: Storage<E,N,M>, SV1: Storage<E,M,K> + Clone, SV2: StorageMut<E,N,K>, |
67 where SM: Storage<E,N,M>, SV1: Storage<E,M,K> + Clone, |
|
68 OMatrix<E, N, K> : AXPY<E>, |
68 N : Dim, M : Dim, K : Dim, E : Scalar + Zero + One + Float, |
69 N : Dim, M : Dim, K : Dim, E : Scalar + Zero + One + Float, |
69 DefaultAllocator : Allocator<N,K>, |
70 DefaultAllocator : Allocator<N,K>, |
70 DefaultAllocator : Allocator<M,K>, |
71 DefaultAllocator : Allocator<M,K>, |
71 DefaultAllocator : Allocator<N,M>, |
72 DefaultAllocator : Allocator<N,M>, |
72 DefaultAllocator : Allocator<M,N> { |
73 DefaultAllocator : Allocator<M,N> { |
73 |
74 |
74 #[inline] |
75 #[inline] |
75 fn gemv<I : Instance<Matrix<E,M,K,SV1>>>( |
76 fn gemv<I : Instance<Matrix<E,M,K,SV1>>>( |
76 &self, y : &mut Matrix<E,N,K,SV2>, α : E, x : I, β : E |
77 &self, y : &mut OMatrix<E,N,K>, α : E, x : I, β : E |
77 ) { |
78 ) { |
78 x.eval(|x̃| Matrix::gemm(y, α, self, x̃, β)) |
79 x.eval(|x̃| Matrix::gemm(y, α, self, x̃, β)) |
79 } |
80 } |
80 |
81 |
81 #[inline] |
82 #[inline] |
82 fn apply_mut<'a, I : Instance<Matrix<E,M,K,SV1>>>(&self, y : &mut Matrix<E,N,K,SV2>, x : I) { |
83 fn apply_mut<'a, I : Instance<Matrix<E,M,K,SV1>>>(&self, y : &mut OMatrix<E,N,K>, x : I) { |
83 x.eval(|x̃| self.mul_to(x̃, y)) |
84 x.eval(|x̃| self.mul_to(x̃, y)) |
84 } |
85 } |
85 } |
86 } |
86 |
87 |
87 impl<SM,SV1,M,E> AXPY<E, Vector<E,M,SV1>> for Vector<E,M,SM> |
88 impl<SM,M,E> AXPY<E, OVector<E, M>> for Vector<E,M,SM> |
88 where SM: StorageMut<E,M> + Clone, SV1: Storage<E,M> + Clone, |
89 where SM: StorageMut<E,M> + Clone, |
89 M : Dim, E : Scalar + Zero + One + Float, |
90 M : Dim, E : Scalar + Zero + One + Float, |
90 DefaultAllocator : Allocator<M> { |
91 DefaultAllocator : Allocator<M> { |
91 type Owned = OVector<E, M>; |
92 |
92 |
93 #[inline] |
93 #[inline] |
94 fn add_mul<I : Instance<OVector<E, M>>>(self, α : E, x : I, β : E) -> OVector<E, M> { |
94 fn add_mul<I : Instance<Vector<E,M,SV1>>>(self, α : E, x : I, β : E) -> Self::Owned { |
|
95 let mut owned = self.into_owned(); |
95 let mut owned = self.into_owned(); |
96 x.eval(|x̃| Matrix::axpy(&mut owned, α, x̃, β)); |
96 x.eval(|x̃| Matrix::axpy(&mut owned, α, x̃, β)); |
97 owned |
97 owned |
98 } |
98 } |
99 |
99 |
100 #[inline] |
100 #[inline] |
101 fn axpy<I : Instance<Vector<E,M,SV1>>>(&mut self, α : E, x : I, β : E) { |
101 fn axpy<I : Instance<OVector<E, M>>>(&mut self, α : E, x : I, β : E) { |
102 x.eval(|x̃| Matrix::axpy(self, α, x̃, β)) |
102 x.eval(|x̃| Matrix::axpy(self, α, x̃, β)) |
103 } |
103 } |
104 |
104 |
105 #[inline] |
105 #[inline] |
106 fn copy_from<I : Instance<Vector<E,M,SV1>>>(&mut self, y : I) { |
106 fn copy_from<I : Instance<OVector<E, M>>>(&mut self, y : I) { |
107 y.eval(|ỹ| Matrix::copy_from(self, ỹ)) |
107 y.eval(|ỹ| Matrix::copy_from(self, ỹ)) |
108 } |
108 } |
109 |
109 |
110 #[inline] |
110 #[inline] |
111 fn set_zero(&mut self) { |
111 fn set_zero(&mut self) { |
112 self.iter_mut().for_each(|e| *e = E::ZERO); |
112 self.iter_mut().for_each(|e| *e = E::ZERO); |
113 } |
113 } |
114 |
114 |
115 #[inline] |
115 #[inline] |
116 fn similar_origin(&self) -> Self::Owned { |
116 fn similar_origin(&self) -> OVector<E, M> { |
117 OVector::zeros_generic(M::from_usize(self.len()), Const) |
117 OVector::zeros_generic(M::from_usize(self.len()), Const) |
118 } |
118 } |
119 } |
119 } |
120 |
120 |
121 /* Implemented automatically as Euclidean. |
121 /* Implemented automatically as Euclidean. |