Mon, 05 Dec 2022 23:50:22 +0200
Zenodo packaging hacks
35 | 1 | /*! |
2 | Simple parametric forward model. | |
3 | */ | |
4 | ||
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
5 | use super::{AdjointProductBoundedBy, AdjointProductPairBoundedBy, BoundedCurvature, ForwardModel}; |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
6 | use crate::measures::RNDM; |
35 | 7 | use alg_tools::direct_product::Pair; |
8 | use alg_tools::error::DynError; | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
9 | use alg_tools::linops::{IdOp, Linear, RowOp, ZeroOp, AXPY}; |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
10 | use alg_tools::mapping::Space; |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
11 | use alg_tools::norms::{Norm, NormExponent, PairNorm, L2}; |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
12 | use alg_tools::types::{ClosedAdd, Float}; |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
13 | use numeric_literals::replace_float_literals; |
35 | 14 | |
15 | impl<Domain, F, A, E> ForwardModel<Pair<Domain, A::Observable>, F, PairNorm<E, L2, L2>> | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
16 | for RowOp<A, IdOp<A::Observable>> |
35 | 17 | where |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
18 | E: NormExponent, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
19 | Domain: Space + Norm<F, E>, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
20 | F: Float, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
21 | A::Observable: ClosedAdd + Norm<F, L2> + 'static, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
22 | A: ForwardModel<Domain, F, E> + 'static, |
35 | 23 | { |
24 | type Observable = A::Observable; | |
25 | ||
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
26 | fn write_observable(&self, b: &Self::Observable, prefix: String) -> DynError { |
35 | 27 | self.0.write_observable(b, prefix) |
28 | } | |
29 | ||
30 | /// Returns a zero observable | |
31 | fn zero_observable(&self) -> Self::Observable { | |
32 | self.0.zero_observable() | |
33 | } | |
34 | } | |
35 | ||
36 | #[replace_float_literals(F::cast_from(literal))] | |
37 | impl<Domain, F, A, D, Z> AdjointProductPairBoundedBy<Pair<Domain, Z>, D, IdOp<Z>> | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
38 | for RowOp<A, IdOp<Z>> |
35 | 39 | where |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
40 | Domain: Space, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
41 | F: Float, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
42 | Z: Clone + Space + ClosedAdd, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
43 | A: AdjointProductBoundedBy<Domain, D, FloatType = F, Codomain = Z>, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
44 | A::Codomain: ClosedAdd, |
35 | 45 | { |
46 | type FloatType = F; | |
47 | ||
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
48 | fn adjoint_product_pair_bound(&self, d: &D, _: &IdOp<Z>) -> Option<(F, F)> { |
35 | 49 | self.0.adjoint_product_bound(d).map(|l_0| { |
50 | // [A_*; B_*][A, B] = [A_*A, A_* B; B_* A, B_* B] ≤ diag(2A_*A, 2B_*B) | |
51 | // ≤ diag(2l_A𝒟_A, 2l_B𝒟_B), where now 𝒟_B=Id and l_B=1. | |
52 | (2.0 * l_0, 2.0) | |
53 | }) | |
54 | } | |
55 | } | |
56 | ||
44 | 57 | /* |
35 | 58 | /// This `impl` is bit of an abuse as the codomain of `Apre` is a [`Pair`] of a measure predual, |
59 | /// to which this `impl` applies, and another space. | |
60 | impl<F, Apre, Z> LipschitzValues | |
61 | for ColOp<Apre, IdOp<Z>> | |
62 | where | |
63 | F : Float, | |
64 | Z : Clone + Space + ClosedAdd, | |
65 | Apre : LipschitzValues<FloatType = F>, | |
66 | { | |
67 | type FloatType = F; | |
68 | /// Return (if one exists) a factor $L$ such that $A_*z$ is $L$-Lipschitz for all | |
69 | /// $z$ in the unit ball. | |
70 | fn value_unit_lipschitz_factor(&self) -> Option<Self::FloatType> { | |
71 | self.0.value_unit_lipschitz_factor() | |
72 | } | |
73 | ||
74 | /// Return (if one exists) a factor $L$ such that $∇A_*z$ is $L$-Lipschitz for all | |
75 | /// $z$ in the unit ball. | |
76 | fn value_diff_unit_lipschitz_factor(&self) -> Option<Self::FloatType> { | |
77 | self.0.value_diff_unit_lipschitz_factor() | |
78 | } | |
79 | } | |
44 | 80 | */ |
35 | 81 | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
82 | impl<F, A, Z> BoundedCurvature for RowOp<A, IdOp<Z>> |
44 | 83 | where |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
84 | F: Float, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
85 | Z: Clone + Space + ClosedAdd, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
86 | A: BoundedCurvature<FloatType = F>, |
44 | 87 | { |
35 | 88 | type FloatType = F; |
89 | ||
44 | 90 | fn curvature_bound_components(&self) -> (Option<Self::FloatType>, Option<Self::FloatType>) { |
91 | self.0.curvature_bound_components() | |
35 | 92 | } |
93 | } | |
94 | ||
95 | #[replace_float_literals(F::cast_from(literal))] | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
96 | impl<'a, F, D, XD, Y, const N: usize> AdjointProductBoundedBy<RNDM<F, N>, D> |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
97 | for ZeroOp<'a, RNDM<F, N>, XD, Y, F> |
35 | 98 | where |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
99 | F: Float, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
100 | Y: AXPY<F> + Clone, |
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
101 | D: Linear<RNDM<F, N>>, |
35 | 102 | { |
103 | type FloatType = F; | |
104 | /// Return $L$ such that $A_*A ≤ L𝒟$ is bounded by some `other` operator $𝒟$. | |
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
44
diff
changeset
|
105 | fn adjoint_product_bound(&self, _: &D) -> Option<F> { |
35 | 106 | Some(0.0) |
107 | } | |
108 | } |