| 2 Abstract linear operators. |
2 Abstract linear operators. |
| 3 */ |
3 */ |
| 4 |
4 |
| 5 use crate::direct_product::Pair; |
5 use crate::direct_product::Pair; |
| 6 use crate::error::DynResult; |
6 use crate::error::DynResult; |
| |
7 use crate::euclidean::StaticEuclidean; |
| 7 use crate::instance::Instance; |
8 use crate::instance::Instance; |
| 8 pub use crate::mapping::{ClosedSpace, Composition, DifferentiableImpl, Mapping, Space}; |
9 pub use crate::mapping::{ClosedSpace, Composition, DifferentiableImpl, Mapping, Space}; |
| 9 use crate::norms::{HasDual, Linfinity, Norm, NormExponent, PairNorm, L1, L2}; |
10 use crate::norms::{HasDual, Linfinity, Norm, NormExponent, PairNorm, L1, L2}; |
| 10 use crate::types::*; |
11 use crate::types::*; |
| 11 use numeric_literals::replace_float_literals; |
12 use numeric_literals::replace_float_literals; |
| 169 |
170 |
| 170 /// Variant of [`Adjointable`] where the adjoint does not depend on a lifetime parameter. |
171 /// Variant of [`Adjointable`] where the adjoint does not depend on a lifetime parameter. |
| 171 /// This exists due to restrictions of Rust's type system: if `A :: Adjointable`, and we make |
172 /// This exists due to restrictions of Rust's type system: if `A :: Adjointable`, and we make |
| 172 /// further restrictions on the adjoint operator, through, e.g. |
173 /// further restrictions on the adjoint operator, through, e.g. |
| 173 /// ``` |
174 /// ``` |
| 174 /// for<'a> A::Adjoint<'a> : GEMV<F, X, Y>, |
175 /// for<'a> A::Adjoint<'a> : GEMV<F, Z, Y>, |
| 175 /// ``` |
176 /// ``` |
| 176 /// Then `'static` lifetime is forced on `X`. Having `A::SimpleAdjoint` not depend on `'a` |
177 /// Then `'static` lifetime is forced on `X`. Having `A::SimpleAdjoint` not depend on `'a` |
| 177 /// avoids this, but makes it impossible for the adjoint to be just a light wrapper around the |
178 /// avoids this, but makes it impossible for the adjoint to be just a light wrapper around the |
| 178 /// original operator. |
179 /// original operator. |
| 179 pub trait SimplyAdjointable<X, Yʹ>: Linear<X> |
180 pub trait SimplyAdjointable<X, Yʹ>: Linear<X> |
| 358 where |
359 where |
| 359 Self: 'b; |
360 Self: 'b; |
| 360 |
361 |
| 361 fn origin(&self) -> Y::PrincipalV; |
362 fn origin(&self) -> Y::PrincipalV; |
| 362 fn as_ref(&self) -> Self::Ref<'_>; |
363 fn as_ref(&self) -> Self::Ref<'_>; |
| |
364 } |
| |
365 |
| |
366 #[derive(Copy, Clone, Debug)] |
| |
367 pub struct StaticEuclideanOriginGenerator; |
| |
368 |
| |
369 impl<Y: StaticEuclidean> OriginGenerator<Y> for StaticEuclideanOriginGenerator { |
| |
370 type Ref<'b> |
| |
371 = Self |
| |
372 where |
| |
373 Self: 'b; |
| |
374 |
| |
375 #[inline] |
| |
376 fn origin(&self) -> Y::PrincipalV { |
| |
377 return Y::origin(); |
| |
378 } |
| |
379 |
| |
380 #[inline] |
| |
381 fn as_ref(&self) -> Self::Ref<'_> { |
| |
382 *self |
| |
383 } |
| 363 } |
384 } |
| 364 |
385 |
| 365 impl<Y: VectorSpace> OriginGenerator<Y> for Y { |
386 impl<Y: VectorSpace> OriginGenerator<Y> for Y { |
| 366 type Ref<'b> |
387 type Ref<'b> |
| 367 = &'b Y |
388 = &'b Y |