src/forward_model/sensor_grid.rs

Thu, 19 Mar 2026 18:21:17 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 19 Mar 2026 18:21:17 -0500
branch
dev
changeset 67
95bb12bdb6ac
parent 61
4f468d35fa29
permissions
-rw-r--r--

Remove apparently now unused dec2flt feature request

35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 /*!
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2 Sensor grid forward model
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 */
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
5 use super::{BasicCurvatureBoundEstimates, ForwardModel};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
6 use crate::frank_wolfe::FindimQuadraticModel;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
7 use crate::kernels::{AutoConvolution, BoundedBy, Convolution};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
8 use crate::measures::{DiscreteMeasure, Radon, RNDM};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
9 use crate::preadjoint_helper::PreadjointHelper;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
10 use crate::seminorms::{ConvolutionOp, SimpleConvolutionKernel};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
11 use crate::types::*;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
12 use alg_tools::bisection_tree::*;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
13 use alg_tools::bounds::Bounded;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
14 use alg_tools::error::{DynError, DynResult};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
15 use alg_tools::euclidean::Euclidean;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
16 use alg_tools::instance::Instance;
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
17 use alg_tools::iter::{MapX, Mappable};
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
18 use alg_tools::lingrid::*;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
19 pub use alg_tools::linops::*;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
20 use alg_tools::mapping::{DifferentiableMapping, RealMapping};
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
21 use alg_tools::maputil::map2;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
22 use alg_tools::nalgebra_support::ToNalgebraRealField;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
23 use alg_tools::norms::{Linfinity, Norm, L1, L2};
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
24 use alg_tools::tabledump::write_csv;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
25 use anyhow::anyhow;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
26 use nalgebra::base::{DMatrix, DVector};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
27 use numeric_literals::replace_float_literals;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
28 use std::iter::Zip;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
29 use std::ops::RangeFrom;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
30
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
31 pub type ShiftedSensor<F, S, P, const N: usize> = Shift<Convolution<S, P>, N, F>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
32
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
33 /// Trait for physical convolution models. Has blanket implementation for all cases.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
34 pub trait Spread<const N: usize, F: Float = f64>:
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
35 'static + Clone + Support<N, F> + RealMapping<N, F> + Bounded<F>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
36 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
37 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
38
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
39 impl<F, T, const N: usize> Spread<N, F> for T
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
40 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
41 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
42 T: 'static + Clone + Support<N, F> + Bounded<F> + RealMapping<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
43 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
44 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
45
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
46 /// Trait for compactly supported sensors. Has blanket implementation for all cases.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
47 pub trait Sensor<const N: usize, F: Float = f64>:
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
48 Spread<N, F> + Norm<L1, F> + Norm<Linfinity, F>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
49 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
50 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
51
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
52 impl<F, T, const N: usize> Sensor<N, F> for T
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
53 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
54 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
55 T: Spread<N, F> + Norm<L1, F> + Norm<Linfinity, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
56 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
57 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
58
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
59 pub trait SensorGridBT<F, S, P, const N: usize>:
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
60 Clone + BTImpl<N, F, Data = usize, Agg = Bounds<F>>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
61 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
62 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
63 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
64 P: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
65 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
66 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
67
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
68 impl<F, S, P, T, const N: usize> SensorGridBT<F, S, P, N> for T
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
69 where
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
70 T: Clone + BTImpl<N, F, Data = usize, Agg = Bounds<F>>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
71 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
72 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
73 P: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
74 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
75 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
76
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
77 // We need type alias bounds to access associated types
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
78 #[allow(type_alias_bounds)]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
79 pub type SensorGridBTFN<F, S, P, BT: SensorGridBT<F, S, P, N>, const N: usize> =
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
80 BTFN<F, SensorGridSupportGenerator<S, F, P, N>, BT, N>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
81
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
82 /// Sensor grid forward model
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
83 #[derive(Clone)]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
84 pub struct SensorGrid<F, S, P, BT, const N: usize>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
85 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
86 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
87 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
88 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
89 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
90 BT: SensorGridBT<F, S, P, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
91 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
92 domain: Cube<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
93 sensor_count: [usize; N],
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
94 sensor: S,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
95 spread: P,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
96 base_sensor: Convolution<S, P>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
97 bt: BT,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
98 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
99
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
100 impl<F, S, P, BT, const N: usize> SensorGrid<F, S, P, BT, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
101 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
102 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
103 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
104 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
105 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
106 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, BT::Agg, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
107 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
108 /// Create a new sensor grid.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
109 ///
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
110 /// The parameter `depth` indicates the search depth of the created [`BT`]s
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
111 /// for the adjoint values.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
112 pub fn new(
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
113 domain: Cube<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
114 sensor_count: [usize; N],
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
115 sensor: S,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
116 spread: P,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
117 depth: BT::Depth,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
118 ) -> Self {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
119 let base_sensor = Convolution(sensor.clone(), spread.clone());
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
120 let bt = BT::new(domain, depth);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
121 let mut sensorgrid = SensorGrid {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
122 domain,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
123 sensor_count,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
124 sensor,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
125 spread,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
126 base_sensor,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
127 bt,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
128 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
129
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
130 for (x, id) in sensorgrid.grid().into_iter().zip(0usize..) {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
131 let s = sensorgrid.shifted_sensor(x);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
132 sensorgrid.bt.insert(id, &s);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
133 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
134
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
135 sensorgrid
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
136 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
137 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
138
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
139 impl<F, S, P, BT, const N: usize> SensorGrid<F, S, P, BT, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
140 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
141 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
142 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
143 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
144 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
145 Convolution<S, P>: Spread<N, F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
146 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
147 /// Return the grid of sensor locations.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
148 pub fn grid(&self) -> LinGrid<N, F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
149 lingrid_centered(&self.domain, &self.sensor_count)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
150 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
151
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
152 /// Returns the number of sensors (number of grid points)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
153 pub fn n_sensors(&self) -> usize {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
154 self.sensor_count.iter().product()
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
155 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
156
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
157 /// Constructs a sensor shifted by `x`.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
158 #[inline]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
159 fn shifted_sensor(&self, x: Loc<N, F>) -> ShiftedSensor<F, S, P, N> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
160 self.base_sensor.clone().shift(x)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
161 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
162
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
163 #[inline]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
164 fn _zero_observable(&self) -> DVector<F> {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
165 DVector::zeros(self.n_sensors())
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
166 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
167
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
168 /// Returns the maximum number of overlapping sensors $N_\psi$.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
169 pub fn max_overlapping(&self) -> F {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
170 let w = self.base_sensor.support_hint().width();
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
171 let d = map2(self.domain.width(), &self.sensor_count, |wi, &i| {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
172 wi / F::cast_from(i)
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
173 });
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
174 w.iter()
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
175 .zip(d.iter())
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
176 .map(|(&wi, &di)| (wi / di).ceil())
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
177 .reduce(F::mul)
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
178 .unwrap()
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
179 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
180 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
181
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
182 impl<F, S, P, BT, const N: usize> Mapping<RNDM<N, F>> for SensorGrid<F, S, P, BT, N>
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
183 where
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
184 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
185 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
186 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
187 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
188 Convolution<S, P>: Spread<N, F>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
189 {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
190 type Codomain = DVector<F>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
191
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
192 #[inline]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
193 fn apply<I: Instance<RNDM<N, F>>>(&self, μ: I) -> DVector<F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
194 let mut y = self._zero_observable();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
195 self.apply_add(&mut y, μ);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
196 y
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
197 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
198 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
199
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
200 impl<F, S, P, BT, const N: usize> Linear<RNDM<N, F>> for SensorGrid<F, S, P, BT, N>
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
201 where
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
202 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
203 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
204 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
205 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
206 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
207 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
208 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
209
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
210 #[replace_float_literals(F::cast_from(literal))]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
211 impl<F, S, P, BT, const N: usize> GEMV<F, RNDM<N, F>, DVector<F>> for SensorGrid<F, S, P, BT, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
212 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
213 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
214 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
215 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
216 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
217 Convolution<S, P>: Spread<N, F>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
218 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
219 fn gemv<I: Instance<RNDM<N, F>>>(&self, y: &mut DVector<F>, α: F, μ: I, β: F) {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
220 let grid = self.grid();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
221 if β == 0.0 {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
222 y.fill(0.0)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
223 } else if β != 1.0 {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
224 *y *= β; // Need to multiply first, as we have to be able to add to y.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
225 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
226 if α == 1.0 {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
227 self.apply_add(y, μ)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
228 } else {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
229 μ.eval_ref(|μr| {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
230 for δ in μr {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
231 for &d in self.bt.iter_at(&δ.x) {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
232 let sensor = self.shifted_sensor(grid.entry_linear_unchecked(d));
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
233 y[d] += sensor.apply(&δ.x) * (α * δ.α);
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
234 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
235 }
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
236 })
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
237 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
238 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
239
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
240 fn apply_add<I: Instance<RNDM<N, F>>>(&self, y: &mut DVector<F>, μ: I) {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
241 let grid = self.grid();
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
242 μ.eval_ref(|μr| {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
243 for δ in μr {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
244 for &d in self.bt.iter_at(&δ.x) {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
245 let sensor = self.shifted_sensor(grid.entry_linear_unchecked(d));
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
246 y[d] += sensor.apply(&δ.x) * δ.α;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
247 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
248 }
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
249 })
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
250 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
251 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
252
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
253 impl<F, S, P, BT, const N: usize> BoundedLinear<RNDM<N, F>, Radon, L2, F>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
254 for SensorGrid<F, S, P, BT, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
255 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
256 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
257 BT: SensorGridBT<F, S, P, N>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
258 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
259 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
260 Convolution<S, P>: Spread<N, F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
261 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
262 /// An estimate on the operator norm in $𝕃(ℳ(Ω); ℝ^n)$ with $ℳ(Ω)$ equipped
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
263 /// with the Radon norm, and $ℝ^n$ with the Euclidean norm.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
264 fn opnorm_bound(&self, _: Radon, _: L2) -> DynResult<F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
265 // With {x_i}_{i=1}^n the grid centres and φ the kernel, we have
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
266 // |Aμ|_2 = sup_{|z|_2 ≤ 1} ⟨z,Αμ⟩ = sup_{|z|_2 ≤ 1} ⟨A^*z|μ⟩
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
267 // ≤ sup_{|z|_2 ≤ 1} |A^*z|_∞ |μ|_ℳ
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
268 // = sup_{|z|_2 ≤ 1} |∑ φ(· - x_i)z_i|_∞ |μ|_ℳ
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
269 // ≤ sup_{|z|_2 ≤ 1} |φ(y)| ∑_{i:th sensor active at y}|z_i| |μ|_ℳ
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
270 // where the supremum of |∑ φ(· - x_i)z_i|_∞ is reached at y
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
271 // ≤ sup_{|z|_2 ≤ 1} |φ|_∞ √N_ψ |z|_2 |μ|_ℳ
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
272 // where N_ψ is the maximum number of sensors that overlap, and
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
273 // |z|_2 is restricted to the active sensors.
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
274 // = |φ|_∞ √N_ψ |μ|_ℳ.
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
275 // Hence
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
276 let n = self.max_overlapping();
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
277 Ok(self.base_sensor.bounds().uniform() * n.sqrt())
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
278 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
279 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
280
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
281 type SensorGridPreadjoint<'a, A, F, const N: usize> = PreadjointHelper<'a, A, RNDM<N, F>>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
282
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
283 impl<F, S, P, BT, const N: usize> Preadjointable<RNDM<N, F>, DVector<F>>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
284 for SensorGrid<F, S, P, BT, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
285 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
286 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
287 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
288 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
289 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
290 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, BT::Agg, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
291 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
292 type PreadjointCodomain = BTFN<F, SensorGridSupportGenerator<S, F, P, N>, BT, N>;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
293 type Preadjoint<'a>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
294 = SensorGridPreadjoint<'a, Self, F, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
295 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
296 Self: 'a;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
297
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
298 fn preadjoint(&self) -> Self::Preadjoint<'_> {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
299 PreadjointHelper::new(self)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
300 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
301 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
302
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
303 /*
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
304 #[replace_float_literals(F::cast_from(literal))]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
305 impl<'a, F, S, P, BT, const N : usize> LipschitzValues
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
306 for SensorGridPreadjoint<'a, SensorGrid<F, S, P, BT, N>, F, N>
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
307 where F : Float,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
308 BT : SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
309 S : Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
310 P : Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
311 Convolution<S, P> : Spread<N, F> + Lipschitz<L2, FloatType=F> + DifferentiableMapping<Loc<N, F>> + LocalAnalysis<F, BT::Agg, N>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
312 for<'b> <Convolution<S, P> as DifferentiableMapping<Loc<N, F>>>::Differential<'b> : Lipschitz<L2, FloatType=F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
313 {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
314
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
315 type FloatType = F;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
316
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
317 fn value_unit_lipschitz_factor(&self) -> Option<F> {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
318 // The Lipschitz factor of the sensors has to be scaled by the square root of twice
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
319 // the number of overlapping sensors at a single ponit, as Lipschitz estimates involve
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
320 // two points.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
321 let fw = self.forward_op;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
322 let n = fw.max_overlapping();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
323 fw.base_sensor.lipschitz_factor(L2).map(|l| (2.0 * n).sqrt() * l)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
324 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
325
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
326 fn value_diff_unit_lipschitz_factor(&self) -> Option<F> {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
327 // The Lipschitz factor of the sensors has to be scaled by the square root of twice
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
328 // the number of overlapping sensors at a single ponit, as Lipschitz estimates involve
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
329 // two points.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
330 let fw = self.forward_op;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
331 let n = fw.max_overlapping();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
332 fw.base_sensor.diff_ref().lipschitz_factor(L2).map(|l| (2.0 * n).sqrt() * l)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
333 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
334 }
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
335 */
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
336
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
337 #[replace_float_literals(F::cast_from(literal))]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
338 impl<'a, F, S, P, BT, const N: usize> BasicCurvatureBoundEstimates<F> for SensorGrid<F, S, P, BT, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
339 where
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
340 F: Float + ToNalgebraRealField,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
341 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
342 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
343 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
344 DVector<F>: Euclidean<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
345 Convolution<S, P>: Spread<N, F>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
346 + Lipschitz<L2, FloatType = F>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
347 + DifferentiableMapping<Loc<N, F>>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
348 + LocalAnalysis<F, BT::Agg, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
349 for<'b> <Convolution<S, P> as DifferentiableMapping<Loc<N, F>>>::Differential<'b>:
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
350 Lipschitz<L2, FloatType = F>,
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
351 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
352 fn basic_curvature_bound_components(&self) -> (DynResult<F>, DynResult<F>) {
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
353 let n_ψ = self.max_overlapping();
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
354 let ψ_diff_lip = self.base_sensor.diff_ref().lipschitz_factor(L2);
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
355 let ψ_lip = self.base_sensor.lipschitz_factor(L2);
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
356 let ℓ_F0 = ψ_diff_lip.map(|l| (2.0 * n_ψ).sqrt() * l);
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
357 let Θ2 = ψ_lip.map(|l| 4.0 * n_ψ * l.powi(2));
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
358
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
359 (ℓ_F0, Θ2)
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
360 }
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
361 }
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
362
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
363 #[derive(Clone, Debug)]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
364 pub struct SensorGridSupportGenerator<S, F, P, const N: usize>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
365 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
366 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
367 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
368 P: Spread<N, F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
369 {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
370 base_sensor: Convolution<S, P>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
371 grid: LinGrid<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
372 weights: DVector<F>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
373 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
374
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
375 impl<F, S, P, const N: usize> SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
376 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
377 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
378 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
379 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
380 Convolution<S, P>: Spread<N, F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
381 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
382 #[inline]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
383 fn construct_sensor(&self, id: usize, w: F) -> Weighted<ShiftedSensor<F, S, P, N>, F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
384 let x = self.grid.entry_linear_unchecked(id);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
385 self.base_sensor.clone().shift(x).weigh(w)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
386 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
387
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
388 #[inline]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
389 fn construct_sensor_and_id<'a>(
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
390 &'a self,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
391 (id, w): (usize, &'a F),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
392 ) -> (usize, Weighted<ShiftedSensor<F, S, P, N>, F>) {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
393 (id.into(), self.construct_sensor(id, *w))
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
394 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
395 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
396
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
397 impl<F, S, P, const N: usize> SupportGenerator<N, F> for SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
398 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
399 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
400 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
401 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
402 Convolution<S, P>: Spread<N, F>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
403 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
404 type Id = usize;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
405 type SupportType = Weighted<ShiftedSensor<F, S, P, N>, F>;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
406 type AllDataIter<'a>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
407 = MapX<
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
408 'a,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
409 Zip<RangeFrom<usize>, std::slice::Iter<'a, F>>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
410 Self,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
411 (Self::Id, Self::SupportType),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
412 >
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
413 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
414 Self: 'a;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
415
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
416 #[inline]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
417 fn support_for(&self, d: Self::Id) -> Self::SupportType {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
418 self.construct_sensor(d, self.weights[d])
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
419 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
420
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
421 #[inline]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
422 fn support_count(&self) -> usize {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
423 self.weights.len()
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
424 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
425
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
426 #[inline]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
427 fn all_data(&self) -> Self::AllDataIter<'_> {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
428 (0..)
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
429 .zip(self.weights.as_slice().iter())
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
430 .mapX(self, Self::construct_sensor_and_id)
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
431 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
432 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
433
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
434 impl<F, S, P, BT, const N: usize> ForwardModel<DiscreteMeasure<Loc<N, F>, F>, F>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
435 for SensorGrid<F, S, P, BT, N>
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
436 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
437 F: Float + ToNalgebraRealField<MixedType = F> + nalgebra::RealField,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
438 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
439 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
440 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
441 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, BT::Agg, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
442 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
443 type Observable = DVector<F>;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
444
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
445 fn write_observable(&self, b: &Self::Observable, prefix: String) -> DynError {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
446 let it = self.grid().into_iter().zip(b.iter()).map(|(x, &v)| (x, v));
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
447 write_csv(it, prefix + ".txt")
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
448 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
449
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
450 #[inline]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
451 fn zero_observable(&self) -> Self::Observable {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
452 self._zero_observable()
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
453 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
454 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
455
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
456 impl<F, S, P, BT, const N: usize> FindimQuadraticModel<Loc<N, F>, F> for SensorGrid<F, S, P, BT, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
457 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
458 F: Float + ToNalgebraRealField<MixedType = F> + nalgebra::RealField,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
459 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
460 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
461 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
462 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, BT::Agg, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
463 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
464 fn findim_quadratic_model(
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
465 &self,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
466 μ: &DiscreteMeasure<Loc<N, F>, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
467 b: &Self::Observable,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
468 ) -> (DMatrix<F::MixedType>, DVector<F::MixedType>) {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
469 assert_eq!(b.len(), self.n_sensors());
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
470 let mut mA = DMatrix::zeros(self.n_sensors(), μ.len());
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
471 let grid = self.grid();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
472 for (mut mAcol, δ) in mA.column_iter_mut().zip(μ.iter_spikes()) {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
473 for &d in self.bt.iter_at(&δ.x) {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
474 let sensor = self.shifted_sensor(grid.entry_linear_unchecked(d));
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
475 mAcol[d] += sensor.apply(&δ.x);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
476 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
477 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
478 let mAt = mA.transpose();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
479 (&mAt * mA, &mAt * b)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
480 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
481 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
482
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
483 /// Implements the calculation a factor $√L$ such that $A_*A ≤ L 𝒟$ for $A$ the forward model
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
484 /// and $𝒟$ a seminorm of suitable form.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
485 ///
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
486 /// **This assumes (but does not check) that the sensors are not overlapping.**
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
487 #[replace_float_literals(F::cast_from(literal))]
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
488 impl<'a, F, BT, S, P, K, const N: usize>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
489 BoundedLinear<RNDM<N, F>, &'a ConvolutionOp<F, K, BT, N>, L2, F> for SensorGrid<F, S, P, BT, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
490 where
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
491 F: Float + ToNalgebraRealField,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
492 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
493 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
494 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
495 Convolution<S, P>: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
496 K: SimpleConvolutionKernel<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
497 AutoConvolution<P>: BoundedBy<F, K>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
498 Weighted<Shift<K, N, F>, F>: LocalAnalysis<F, BT::Agg, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
499 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
500 fn opnorm_bound(&self, seminorm: &'a ConvolutionOp<F, K, BT, N>, _: L2) -> DynResult<F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
501 // Sensors should not take on negative values to allow
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
502 // A_*A to be upper bounded by a simple convolution of `spread`.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
503 // TODO: Do we really need this restriction?
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
504 if self.sensor.bounds().lower() < 0.0 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
505 return Err(anyhow!("Sensor not bounded from below by zero"));
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
506 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
507
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
508 // Calculate the factor $L_1$ for betwee $ℱ[ψ * ψ] ≤ L_1 ℱ[ρ]$ for $ψ$ the base spread
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
509 // and $ρ$ the kernel of the seminorm.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
510 let l1 = AutoConvolution(self.spread.clone()).bounding_factor(seminorm.kernel())?;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
511
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
512 // Calculate the factor for transitioning from $A_*A$ to `AutoConvolution<P>`, where A
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
513 // consists of several `Convolution<S, P>` for the physical model `P` and the sensor `S`.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
514 let l0 = self.sensor.norm(Linfinity) * self.sensor.norm(L1);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
515
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
516 // The final transition factor is:
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
517 Ok((l0 * l1).sqrt())
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
518 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
519 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
520
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
521 macro_rules! make_sensorgridsupportgenerator_scalarop_rhs {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
522 ($trait:ident, $fn:ident, $trait_assign:ident, $fn_assign:ident) => {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
523 impl<F, S, P, const N: usize> std::ops::$trait_assign<F>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
524 for SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
525 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
526 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
527 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
528 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
529 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
530 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
531 fn $fn_assign(&mut self, t: F) {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
532 self.weights.$fn_assign(t);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
533 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
534 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
535
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
536 impl<F, S, P, const N: usize> std::ops::$trait<F> for SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
537 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
538 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
539 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
540 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
541 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
542 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
543 type Output = SensorGridSupportGenerator<S, F, P, N>;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
544 fn $fn(mut self, t: F) -> Self::Output {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
545 std::ops::$trait_assign::$fn_assign(&mut self.weights, t);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
546 self
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
547 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
548 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
549
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
550 impl<'a, F, S, P, const N: usize> std::ops::$trait<F>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
551 for &'a SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
552 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
553 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
554 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
555 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
556 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
557 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
558 type Output = SensorGridSupportGenerator<S, F, P, N>;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
559 fn $fn(self, t: F) -> Self::Output {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
560 SensorGridSupportGenerator {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
561 base_sensor: self.base_sensor.clone(),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
562 grid: self.grid,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
563 weights: (&self.weights).$fn(t),
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
564 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
565 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
566 }
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
567 };
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
568 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
569
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
570 make_sensorgridsupportgenerator_scalarop_rhs!(Mul, mul, MulAssign, mul_assign);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
571 make_sensorgridsupportgenerator_scalarop_rhs!(Div, div, DivAssign, div_assign);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
572
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
573 macro_rules! make_sensorgridsupportgenerator_unaryop {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
574 ($trait:ident, $fn:ident) => {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
575 impl<F, S, P, const N: usize> std::ops::$trait for SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
576 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
577 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
578 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
579 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
580 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
581 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
582 type Output = SensorGridSupportGenerator<S, F, P, N>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
583 fn $fn(mut self) -> Self::Output {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
584 self.weights = self.weights.$fn();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
585 self
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
586 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
587 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
588
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
589 impl<'a, F, S, P, const N: usize> std::ops::$trait
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
590 for &'a SensorGridSupportGenerator<S, F, P, N>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
591 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
592 F: Float,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
593 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
594 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
595 Convolution<S, P>: Spread<N, F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
596 {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
597 type Output = SensorGridSupportGenerator<S, F, P, N>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
598 fn $fn(self) -> Self::Output {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
599 SensorGridSupportGenerator {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
600 base_sensor: self.base_sensor.clone(),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
601 grid: self.grid,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
602 weights: (&self.weights).$fn(),
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
603 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
604 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
605 }
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
606 };
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
607 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
608
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
609 make_sensorgridsupportgenerator_unaryop!(Neg, neg);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
610
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
611 impl<'a, F, S, P, BT, const N: usize> Mapping<DVector<F>>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
612 for PreadjointHelper<'a, SensorGrid<F, S, P, BT, N>, RNDM<N, F>>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
613 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
614 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
615 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
616 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
617 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
618 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, Bounds<F>, N>,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
619 {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
620 type Codomain = SensorGridBTFN<F, S, P, BT, N>;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
621
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
622 fn apply<I: Instance<DVector<F>>>(&self, x: I) -> Self::Codomain {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
623 let fwd = &self.forward_op;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
624 let generator = SensorGridSupportGenerator {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
625 base_sensor: fwd.base_sensor.clone(),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
626 grid: fwd.grid(),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
627 weights: x.own(),
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
628 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
629 BTFN::new_refresh(&fwd.bt, generator)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
630 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
631 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
632
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
633 impl<'a, F, S, P, BT, const N: usize> Linear<DVector<F>>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
634 for PreadjointHelper<'a, SensorGrid<F, S, P, BT, N>, RNDM<N, F>>
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
635 where
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
636 F: Float,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
637 BT: SensorGridBT<F, S, P, N>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
638 S: Sensor<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
639 P: Spread<N, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
640 Convolution<S, P>: Spread<N, F> + LocalAnalysis<F, Bounds<F>, N>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
641 {
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 44
diff changeset
642 }

mercurial