src/mapping/dataterm.rs

branch
dev
changeset 194
a5ee4bfb0b87
parent 191
794833f18a05
equal deleted inserted replaced
193:dccf609cd020 194:a5ee4bfb0b87
110 impl<F, X, Y, A, G> DifferentiableImpl<X> for DataTerm<F, X, A, G> 110 impl<F, X, Y, A, G> DifferentiableImpl<X> for DataTerm<F, X, A, G>
111 where 111 where
112 F: Float, 112 F: Float,
113 X: Space, 113 X: Space,
114 Y: Space + Instance<Y> + for<'a> Sub<&'a Y, Output = Y>, 114 Y: Space + Instance<Y> + for<'a> Sub<&'a Y, Output = Y>,
115 //<A as Mapping<X>>::Codomain: Euclidean<F>,
116 A: Linear<X, Codomain = Y> + Preadjointable<X, G::DerivativeDomain>, 115 A: Linear<X, Codomain = Y> + Preadjointable<X, G::DerivativeDomain>,
117 G::DerivativeDomain: Instance<G::DerivativeDomain>, 116 G::DerivativeDomain: Instance<G::DerivativeDomain>,
118 A::PreadjointCodomain: ClosedSpace, 117 A::PreadjointCodomain: ClosedSpace,
119 //<<A as Mapping<X>>::Codomain as Euclidean<F>>::Output: Instance<<A as Mapping<X>>::Codomain>,
120 G: DifferentiableMapping<Y, Codomain = F>, 118 G: DifferentiableMapping<Y, Codomain = F>,
119 Self: Mapping<X, Codomain = F>,
121 { 120 {
122 type Derivative = A::PreadjointCodomain; 121 type Derivative = A::PreadjointCodomain;
123 122
124 fn differential_impl<I: Instance<X>>(&self, x: I) -> Self::Derivative { 123 fn differential_impl<I: Instance<X>>(&self, x: I) -> Self::Derivative {
125 // TODO: possibly (if at all more effcient) use GEMV once generalised 124 // TODO: possibly (if at all more effcient) use GEMV once generalised
127 // at not doing preallocations or anything here, as the result of self.opA.apply() 126 // at not doing preallocations or anything here, as the result of self.opA.apply()
128 // can be consumed, so maybe GEMV is no use. 127 // can be consumed, so maybe GEMV is no use.
129 //self.opA.preadjoint().apply(self.opA.apply(x) - self.b) 128 //self.opA.preadjoint().apply(self.opA.apply(x) - self.b)
130 self.opA 129 self.opA
131 .preadjoint() 130 .preadjoint()
132 .apply(self.g.diff_ref().apply(self.opA.apply(x) - &self.b)) 131 .apply(self.g.differential(self.opA.apply(x) - &self.b))
132 }
133
134 fn apply_and_differential_impl<I: Instance<X>>(&self, x: I) -> (F, Self::Derivative) {
135 let j = self.opA.apply(x) - &self.b;
136 let (v, d) = self.g.apply_and_differential(j);
137 (v, self.opA.preadjoint().apply(d))
133 } 138 }
134 } 139 }
135 140
136 impl<'a, F, X, Y, A, G> LipschitzDifferentiableImpl<X, X::NormExp> for DataTerm<F, X, A, G> 141 impl<'a, F, X, Y, A, G> LipschitzDifferentiableImpl<X, X::NormExp> for DataTerm<F, X, A, G>
137 where 142 where

mercurial