| 132 $crate::wrap!(impl_scalar_lhs $F, $type, std::ops::Mul, mul where $($qual)*); |
132 $crate::wrap!(impl_scalar_lhs $F, $type, std::ops::Mul, mul where $($qual)*); |
| 133 $crate::wrap!(impl_binary_mut $type, std::ops::AddAssign, add_assign where $($qual)*); |
133 $crate::wrap!(impl_binary_mut $type, std::ops::AddAssign, add_assign where $($qual)*); |
| 134 $crate::wrap!(impl_binary_mut $type, std::ops::SubAssign, sub_assign where $($qual)*); |
134 $crate::wrap!(impl_binary_mut $type, std::ops::SubAssign, sub_assign where $($qual)*); |
| 135 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::MulAssign, mul_assign where $($qual)*); |
135 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::MulAssign, mul_assign where $($qual)*); |
| 136 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::DivAssign, div_assign where $($qual)*); |
136 $crate::wrap!(impl_scalar_mut $F, $type, std::ops::DivAssign, div_assign where $($qual)*); |
| |
137 |
| |
138 $crate::self_ownable!($type where $($qual)*); |
| 137 |
139 |
| 138 impl<$($qual)*> $crate::euclidean::Euclidean<$F> for $type |
140 impl<$($qual)*> $crate::euclidean::Euclidean<$F> for $type |
| 139 // where |
141 // where |
| 140 // Self: $crate::euclidean::wrap::Wrapped<WrappedField = $F> |
142 // Self: $crate::euclidean::wrap::Wrapped<WrappedField = $F> |
| 141 // + Sized |
143 // + Sized |
| 151 // + for<'b> std::ops::AddAssign<&'b Self> |
153 // + for<'b> std::ops::AddAssign<&'b Self> |
| 152 // + std::ops::SubAssign<Self> |
154 // + std::ops::SubAssign<Self> |
| 153 // + for<'b> std::ops::SubAssign<&'b Self> |
155 // + for<'b> std::ops::SubAssign<&'b Self> |
| 154 // + std::ops::Neg<Output = <Self as $crate::linops::AXPY>::Owned>, |
156 // + std::ops::Neg<Output = <Self as $crate::linops::AXPY>::Owned>, |
| 155 { |
157 { |
| |
158 type PrincipalE = Self; |
| |
159 |
| 156 fn dot<I: $crate::instance::Instance<Self>>(&self, other: I) -> $F { |
160 fn dot<I: $crate::instance::Instance<Self>>(&self, other: I) -> $F { |
| 157 other.eval_decompose(|x| self.get_view().dot(&x.get_view())) |
161 other.eval_decompose(|x| self.get_view().dot(&x.get_view())) |
| 158 } |
162 } |
| 159 |
163 |
| 160 fn norm2_squared(&self) -> $F { |
164 fn norm2_squared(&self) -> $F { |
| 164 fn dist2_squared<I: $crate::instance::Instance<Self>>(&self, other: I) -> $F { |
168 fn dist2_squared<I: $crate::instance::Instance<Self>>(&self, other: I) -> $F { |
| 165 other.eval_decompose(|x| self.get_view().dist2_squared(x.get_view())) |
169 other.eval_decompose(|x| self.get_view().dist2_squared(x.get_view())) |
| 166 } |
170 } |
| 167 } |
171 } |
| 168 |
172 |
| 169 impl<$($qual)*> $crate::linops::AXPY for $type |
173 impl<$($qual)*> $crate::linops::VectorSpace for $type |
| 170 // where |
174 // where |
| 171 // Self : $crate::euclidean::wrap::Wrapped<WrappedField = $F>, |
175 // Self : $crate::euclidean::wrap::Wrapped<WrappedField = $F>, |
| 172 // Self::Unwrapped : $crate::linops::AXPY<Field = F>, |
176 // Self::Unwrapped : $crate::linops::AXPY<Field = F>, |
| 173 // Self: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
177 // Self: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
| 174 // Self::Unwrapped: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
178 // Self::Unwrapped: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
| 175 { |
179 { |
| 176 type Field = $F; |
180 type Field = $F; |
| 177 type Owned = Self; |
181 type PrincipalV = Self; |
| 178 |
182 |
| 179 fn axpy<I: $crate::instance::Instance<Self>>(&mut self, α: $F, x: I, β: $F) { |
183 /// Return a similar zero as `self`. |
| |
184 fn similar_origin(&self) -> Self::PrincipalV { |
| |
185 Self::wrap(self.get_view().similar_origin()) |
| |
186 } |
| |
187 } |
| |
188 |
| |
189 impl<$($qual)*> $crate::linops::AXPY for $type |
| |
190 // where |
| |
191 // Self : $crate::euclidean::wrap::Wrapped<WrappedField = $F>, |
| |
192 // Self::Unwrapped : $crate::linops::AXPY<Field = F>, |
| |
193 // Self: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
| |
194 // Self::Unwrapped: std::ops::MulAssign<F> + std::ops::DivAssign<F>, |
| |
195 { |
| |
196 fn axpy<I: $crate::instance::Instance<Self>>(&mut self, α: $F, x: I, β: $F) { |
| 180 x.eval_decompose(|v| { |
197 x.eval_decompose(|v| { |
| 181 self.get_view_mut().axpy(α, v.get_view(), β) |
198 self.get_view_mut().axpy(α, v.get_view(), β) |
| 182 }) |
199 }) |
| 183 } |
200 } |
| 184 |
201 |
| 192 x.eval_decompose(|v| { |
209 x.eval_decompose(|v| { |
| 193 self.get_mut_view().scale_from(α, v.get_view()) |
210 self.get_mut_view().scale_from(α, v.get_view()) |
| 194 }) |
211 }) |
| 195 } |
212 } |
| 196 |
213 |
| 197 /// Return a similar zero as `self`. |
|
| 198 fn similar_origin(&self) -> Self::Owned { |
|
| 199 Self::wrap(self.get_view().similar_origin()) |
|
| 200 } |
|
| 201 |
|
| 202 /// Set self to zero. |
214 /// Set self to zero. |
| 203 fn set_zero(&mut self) { |
215 fn set_zero(&mut self) { |
| 204 self.get_mut_view().set_zero() |
216 self.get_mut_view().set_zero() |
| 205 } |
217 } |
| 206 } |
218 } |
| 207 |
219 |
| 208 impl<$($qual)*> $crate::instance::Space for $type { |
220 impl<$($qual)*> $crate::instance::Space for $type { |
| 209 type Decomp = <<Self as $crate::euclidean::wrap::Wrapped>::Unwrapped as $crate::instance::Space>::Decomp; |
221 type Decomp = <<Self as $crate::euclidean::wrap::Wrapped>::Unwrapped as $crate::instance::Space>::Decomp; |
| |
222 type Principal = Self; |
| 210 } |
223 } |
| 211 }; |
224 }; |
| 212 } |
225 } |