src/convex.rs

branch
dev
changeset 109
943c6b3b9414
parent 108
6be459f08b66
child 112
ed8124f1af1d
equal deleted inserted replaced
108:6be459f08b66 109:943c6b3b9414
14 14
15 /// Trait for convex mappings. Has no features, just serves as a constraint 15 /// Trait for convex mappings. Has no features, just serves as a constraint
16 /// 16 ///
17 /// TODO: should constrain `Mapping::Codomain` to implement a partial order, 17 /// TODO: should constrain `Mapping::Codomain` to implement a partial order,
18 /// but this makes everything complicated with little benefit. 18 /// but this makes everything complicated with little benefit.
19 pub trait ConvexMapping<Domain: Space, F: Num = f64>: Mapping<Domain, Codomain = F> { 19 pub trait ConvexMapping<Domain: Normed<F>, F: Num = f64>: Mapping<Domain, Codomain = F> {
20 /// Returns (a lower estimate of) the factor of strong convexity. 20 /// Returns (a lower estimate of) the factor of strong convexity in the norm of `Domain`.
21 ///
22 /// TODO: should include a specification of the respective norm.
23 fn factor_of_strong_convexity(&self) -> F { 21 fn factor_of_strong_convexity(&self) -> F {
24 F::ZERO 22 F::ZERO
25 } 23 }
26 } 24 }
27 25
41 /// 39 ///
42 /// In contrast to [`Conjugable`], the preconjugate need not implement [`ConvexMapping`], 40 /// In contrast to [`Conjugable`], the preconjugate need not implement [`ConvexMapping`],
43 /// but a `Preconjugable` mapping has to be convex. 41 /// but a `Preconjugable` mapping has to be convex.
44 pub trait Preconjugable<Domain, Predual, F: Num = f64>: ConvexMapping<Domain, F> 42 pub trait Preconjugable<Domain, Predual, F: Num = f64>: ConvexMapping<Domain, F>
45 where 43 where
46 Domain: Space, 44 Domain: Normed<F>,
47 Predual: HasDual<F>, 45 Predual: HasDual<F>,
48 { 46 {
49 type Preconjugate<'a>: Mapping<Predual, Codomain = F> 47 type Preconjugate<'a>: Mapping<Predual, Codomain = F>
50 where 48 where
51 Self: 'a; 49 Self: 'a;
88 norm: NormMapping<F, E>, 86 norm: NormMapping<F, E>,
89 } 87 }
90 88
91 impl<Domain, E, F> ConvexMapping<Domain, F> for NormMapping<F, E> 89 impl<Domain, E, F> ConvexMapping<Domain, F> for NormMapping<F, E>
92 where 90 where
93 Domain: Space, 91 Domain: Normed<F>,
94 E: NormExponent, 92 E: NormExponent,
95 F: Float, 93 F: Float,
96 Self: Mapping<Domain, Codomain = F>, 94 Self: Mapping<Domain, Codomain = F>,
97 { 95 {
98 } 96 }
114 } 112 }
115 } 113 }
116 114
117 impl<Domain, E, F> ConvexMapping<Domain, F> for NormConstraint<F, E> 115 impl<Domain, E, F> ConvexMapping<Domain, F> for NormConstraint<F, E>
118 where 116 where
119 Domain: Space, 117 Domain: Normed<F>,
120 E: NormExponent, 118 E: NormExponent,
121 F: Float, 119 F: Float,
122 Self: Mapping<Domain, Codomain = F>, 120 Self: Mapping<Domain, Codomain = F>,
123 { 121 {
124 } 122 }
125 123
126 impl<E, F, Domain> Conjugable<Domain, F> for NormMapping<F, E> 124 impl<E, F, Domain> Conjugable<Domain, F> for NormMapping<F, E>
127 where 125 where
128 E: HasDualExponent, 126 E: HasDualExponent,
129 F: Float, 127 F: Float,
130 Domain: HasDual<F> + Norm<F, E> + Space, 128 Domain: HasDual<F> + Norm<F, E> + Normed<F>,
131 <Domain as HasDual<F>>::DualSpace: Norm<F, E::DualExp>, 129 <Domain as HasDual<F>>::DualSpace: Norm<F, E::DualExp>,
132 { 130 {
133 type Conjugate<'a> 131 type Conjugate<'a>
134 = NormConstraint<F, E::DualExp> 132 = NormConstraint<F, E::DualExp>
135 where 133 where
207 } 205 }
208 */ 206 */
209 207
210 impl<F, E, Domain> Mapping<Domain> for NormProjection<F, E> 208 impl<F, E, Domain> Mapping<Domain> for NormProjection<F, E>
211 where 209 where
212 Domain: Space + Projection<F, E>, 210 Domain: Normed<F> + Projection<F, E>,
213 F: Float, 211 F: Float,
214 E: NormExponent, 212 E: NormExponent,
215 { 213 {
216 type Codomain = Domain; 214 type Codomain = Domain;
217 215
237 fn apply<I: Instance<Domain>>(&self, _x: I) -> Self::Codomain { 235 fn apply<I: Instance<Domain>>(&self, _x: I) -> Self::Codomain {
238 F::ZERO 236 F::ZERO
239 } 237 }
240 } 238 }
241 239
242 impl<Domain: Space, F: Num> ConvexMapping<Domain, F> for Zero<Domain, F> {} 240 impl<Domain: Normed<F>, F: Float> ConvexMapping<Domain, F> for Zero<Domain, F> {}
243 241
244 impl<Domain: HasDual<F>, F: Float> Conjugable<Domain, F> for Zero<Domain, F> { 242 impl<Domain: HasDual<F>, F: Float> Conjugable<Domain, F> for Zero<Domain, F> {
245 type Conjugate<'a> 243 type Conjugate<'a>
246 = ZeroIndicator<Domain::DualSpace, F> 244 = ZeroIndicator<Domain::DualSpace, F>
247 where 245 where
253 } 251 }
254 } 252 }
255 253
256 impl<Domain, Predual, F: Float> Preconjugable<Domain, Predual, F> for Zero<Domain, F> 254 impl<Domain, Predual, F: Float> Preconjugable<Domain, Predual, F> for Zero<Domain, F>
257 where 255 where
258 Domain: Space, 256 Domain: Normed<F>,
259 Predual: HasDual<F>, 257 Predual: HasDual<F>,
260 { 258 {
261 type Preconjugate<'a> 259 type Preconjugate<'a>
262 = ZeroIndicator<Predual, F> 260 = ZeroIndicator<Predual, F>
263 where 261 where

mercurial