diff -r efa60bc4f743 -r b087e3eab191 src/preadjoint_helper.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/preadjoint_helper.rs Tue Dec 31 09:25:45 2024 -0500 @@ -0,0 +1,55 @@ +/*! +Preadjoint construction helper +*/ + +use std::marker::PhantomData; +use alg_tools::types::*; +pub use alg_tools::linops::*; +use alg_tools::norms::{Norm, HasDualExponent}; + +/// Helper structure for constructing preadjoints of `S` where `S : Linear`. +/// [`Linear`] needs to be implemented for each instance, but [`Adjointable`] +/// and [`BoundedLinear`] have blanket implementations. +#[derive(Clone,Debug)] +pub struct PreadjointHelper<'a, S : 'a, X> { + pub forward_op : &'a S, + _domain : PhantomData +} + +impl<'a, S : 'a, X> PreadjointHelper<'a, S, X> { + pub fn new(forward_op : &'a S) -> Self { + PreadjointHelper { forward_op, _domain: PhantomData } + } +} + +impl<'a, X, Ypre, S> Adjointable +for PreadjointHelper<'a, S, X> +where + X : Space, + Ypre : Space, + Self : Linear, + S : Clone + Linear +{ + type AdjointCodomain = S::Codomain; + type Adjoint<'b> = S where Self : 'b; + + fn adjoint(&self) -> Self::Adjoint<'_> { + self.forward_op.clone() + } +} + +impl<'a, F, X, Ypre, ExpXpre, ExpYpre, S> BoundedLinear +for PreadjointHelper<'a, S, X> +where + ExpXpre : HasDualExponent, + ExpYpre : HasDualExponent, + F : Float, + X : Space + Norm, + Ypre : Space + Norm, + Self : Linear, + S : 'a + Clone + BoundedLinear +{ + fn opnorm_bound(&self, expy : ExpYpre, expx : ExpXpre) -> F { + self.forward_op.opnorm_bound(expx.dual_exponent(), expy.dual_exponent()) + } +}