| 1 /*! |
1 /*! |
| 2 Some convex analysis basics |
2 Some convex analysis basics |
| 3 */ |
3 */ |
| 4 |
4 |
| 5 use std::marker::PhantomData; |
5 use std::marker::PhantomData; |
| |
6 use serde::{Serialize, Deserialize}; |
| 6 use crate::types::*; |
7 use crate::types::*; |
| 7 use crate::mapping::{Mapping, Space}; |
8 use crate::mapping::{Mapping, Space}; |
| 8 use crate::linops::IdOp; |
9 use crate::linops::IdOp; |
| 9 use crate::instance::{Instance, InstanceMut, DecompositionMut}; |
10 use crate::instance::{Instance, InstanceMut, DecompositionMut}; |
| 10 use crate::operator_arithmetic::{Constant, Weighted}; |
11 use crate::operator_arithmetic::{Constant, Weighted}; |
| 66 *y = self.prox(τ, &*y); |
67 *y = self.prox(τ, &*y); |
| 67 } |
68 } |
| 68 } |
69 } |
| 69 |
70 |
| 70 |
71 |
| |
72 #[derive(Serialize,Deserialize,Debug,Clone)] |
| 71 pub struct NormConstraint<F : Float, E : NormExponent> { |
73 pub struct NormConstraint<F : Float, E : NormExponent> { |
| 72 radius : F, |
74 radius : F, |
| 73 norm : NormMapping<F, E>, |
75 norm : NormMapping<F, E>, |
| 74 } |
76 } |
| 75 |
77 |
| 158 assert!(self.radius >= F::ZERO); |
160 assert!(self.radius >= F::ZERO); |
| 159 NormProjection{ radius : self.radius, exponent : self.norm.exponent } |
161 NormProjection{ radius : self.radius, exponent : self.norm.exponent } |
| 160 } |
162 } |
| 161 } |
163 } |
| 162 |
164 |
| |
165 #[derive(Serialize,Deserialize,Debug,Clone)] |
| 163 pub struct NormProjection<F : Float, E : NormExponent> { |
166 pub struct NormProjection<F : Float, E : NormExponent> { |
| 164 radius : F, |
167 radius : F, |
| 165 exponent : E, |
168 exponent : E, |
| 166 } |
169 } |
| 167 |
170 |
| 192 } |
195 } |
| 193 } |
196 } |
| 194 |
197 |
| 195 |
198 |
| 196 /// The zero mapping |
199 /// The zero mapping |
| 197 pub struct Zero<Domain : Space, F : Num>(PhantomData<(Domain, F)>); |
200 #[derive(Serialize,Deserialize,Debug,Clone)] |
| |
201 pub struct Zero<Domain : Space, F : Num>( |
| |
202 #[serde(skip)] |
| |
203 PhantomData<(Domain, F)> |
| |
204 ); |
| 198 |
205 |
| 199 impl<Domain : Space, F : Num> Zero<Domain, F> { |
206 impl<Domain : Space, F : Num> Zero<Domain, F> { |
| 200 pub fn new() -> Self { |
207 pub fn new() -> Self { |
| 201 Zero(PhantomData) |
208 Zero(PhantomData) |
| 202 } |
209 } |
| 245 } |
252 } |
| 246 } |
253 } |
| 247 |
254 |
| 248 |
255 |
| 249 /// The zero indicator |
256 /// The zero indicator |
| 250 pub struct ZeroIndicator<Domain : Space, F : Num>(PhantomData<(Domain, F)>); |
257 #[derive(Serialize,Deserialize,Debug,Clone)] |
| |
258 pub struct ZeroIndicator<Domain : Space, F : Num>( |
| |
259 #[serde(skip)] |
| |
260 PhantomData<(Domain, F)> |
| |
261 ); |
| 251 |
262 |
| 252 impl<Domain : Space, F : Num> ZeroIndicator<Domain, F> { |
263 impl<Domain : Space, F : Num> ZeroIndicator<Domain, F> { |
| 253 pub fn new() -> Self { |
264 pub fn new() -> Self { |
| 254 ZeroIndicator(PhantomData) |
265 ZeroIndicator(PhantomData) |
| 255 } |
266 } |