| 5 |
5 |
| 6 #![allow(non_snake_case)] |
6 #![allow(non_snake_case)] |
| 7 |
7 |
| 8 use super::{DifferentiableImpl, DifferentiableMapping, LipschitzDifferentiableImpl, Mapping}; |
8 use super::{DifferentiableImpl, DifferentiableMapping, LipschitzDifferentiableImpl, Mapping}; |
| 9 use crate::convex::ConvexMapping; |
9 use crate::convex::ConvexMapping; |
| |
10 use crate::error::DynResult; |
| 10 use crate::instance::{Instance, Space}; |
11 use crate::instance::{Instance, Space}; |
| 11 use crate::linops::{BoundedLinear, Linear, Preadjointable}; |
12 use crate::linops::{BoundedLinear, Linear, Preadjointable}; |
| 12 use crate::norms::{Normed, L2}; |
13 use crate::norms::{Normed, L2}; |
| 13 use crate::types::Float; |
14 use crate::types::Float; |
| 14 use std::ops::Sub; |
15 use std::ops::Sub; |
| |
16 |
| 15 //use serde::{Deserialize, Serialize}; |
17 //use serde::{Deserialize, Serialize}; |
| 16 |
18 |
| 17 /// Functions of the form $\frac{1}{2}\|Ax-b\|_2^2$ for an operator $A$ |
19 /// Functions of the form $\frac{1}{2}\|Ax-b\|_2^2$ for an operator $A$ |
| 18 /// to a [`Euclidean`] space. |
20 /// to a [`Euclidean`] space. |
| 19 pub struct DataTerm< |
21 pub struct DataTerm< |
| 112 G: Mapping<Y, Codomain = F> + LipschitzDifferentiableImpl<Y, Y::NormExp>, |
114 G: Mapping<Y, Codomain = F> + LipschitzDifferentiableImpl<Y, Y::NormExp>, |
| 113 Self: DifferentiableImpl<X>, |
115 Self: DifferentiableImpl<X>, |
| 114 { |
116 { |
| 115 type FloatType = F; |
117 type FloatType = F; |
| 116 |
118 |
| 117 fn diff_lipschitz_factor(&self, seminorm: X::NormExp) -> Option<F> { |
119 fn diff_lipschitz_factor(&self, seminorm: X::NormExp) -> DynResult<F> { |
| 118 Some(self.opA.opnorm_bound(seminorm, L2).powi(2)) |
120 Ok(self.opA.opnorm_bound(seminorm, L2)?.powi(2)) |
| 119 } |
121 } |
| 120 } |
122 } |