Thu, 01 May 2025 13:06:58 -0500
Transpose loc parameters to allow f64 defaults
| 5 | 1 | /*! |
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
2 | Traits for representing the support of a [`Mapping`], and analysing the mapping on a [`Cube`]. |
| 5 | 3 | */ |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
4 | use super::aggregator::Bounds; |
|
97
4e80fb049dca
MinMaxMapping trait to allow alternatives to BTFN with relevant properties.
Tuomo Valkonen <tuomov@iki.fi>
parents:
96
diff
changeset
|
5 | pub use crate::bounds::{GlobalAnalysis, LocalAnalysis}; |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
6 | use crate::loc::Loc; |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
7 | use crate::mapping::{DifferentiableImpl, DifferentiableMapping, Instance, Mapping, Space}; |
| 5 | 8 | use crate::maputil::map2; |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
9 | use crate::norms::{Linfinity, Norm, L1, L2}; |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
10 | pub use crate::operator_arithmetic::{Constant, Weighted}; |
| 5 | 11 | use crate::sets::Cube; |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
12 | use crate::types::{Float, Num}; |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
13 | use serde::Serialize; |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
14 | use std::ops::{DivAssign, MulAssign, Neg}; |
| 0 | 15 | |
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
16 | /// A trait for working with the supports of [`Mapping`]s. |
| 5 | 17 | /// |
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
18 | /// `Mapping` is not a super-trait to allow more general use. |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
19 | pub trait Support<const N: usize, F: Num>: Sized + Sync + Send + 'static { |
| 5 | 20 | /// Return a cube containing the support of the function represented by `self`. |
| 21 | /// | |
| 22 | /// The hint may be larger than the actual support, but must contain it. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
23 | fn support_hint(&self) -> Cube<N, F>; |
| 0 | 24 | |
| 5 | 25 | /// Indicate whether `x` is in the support of the function represented by `self`. |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
26 | fn in_support(&self, x: &Loc<N, F>) -> bool; |
| 0 | 27 | |
| 5 | 28 | // Indicate whether `cube` is fully in the support of the function represented by `self`. |
| 0 | 29 | //fn fully_in_support(&self, cube : &Cube<F,N>) -> bool; |
| 30 | ||
| 5 | 31 | /// Return an optional hint for bisecting the support. |
| 32 | /// | |
| 33 | /// The output along each axis a possible coordinate at which to bisect `cube`. | |
| 34 | /// | |
| 35 | /// This is useful for nonsmooth functions to make finite element models as used by | |
| 36 | /// [`BTFN`][super::btfn::BTFN] minimisation/maximisation compatible with points of | |
| 37 | /// non-differentiability. | |
| 38 | /// | |
| 39 | /// The default implementation returns `[None; N]`. | |
| 0 | 40 | #[inline] |
| 5 | 41 | #[allow(unused_variables)] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
42 | fn bisection_hint(&self, cube: &Cube<N, F>) -> [Option<F>; N] { |
| 5 | 43 | [None; N] |
| 0 | 44 | } |
| 45 | ||
| 5 | 46 | /// Translate `self` by `x`. |
| 0 | 47 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
48 | fn shift(self, x: Loc<N, F>) -> Shift<Self, N, F> { |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
49 | Shift { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
50 | shift: x, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
51 | base_fn: self, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
52 | } |
| 0 | 53 | } |
| 54 | } | |
| 55 | ||
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
56 | /// Shift of [`Support`] and [`Mapping`]; output of [`Support::shift`]. |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
57 | #[derive(Copy, Clone, Debug, Serialize)] // Serialize! but not implemented by Loc. |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
58 | pub struct Shift<T, const N: usize, F = f64> { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
59 | shift: Loc<N, F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
60 | base_fn: T, |
| 0 | 61 | } |
| 62 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
63 | impl<'a, T, V: Space, F: Float, const N: usize> Mapping<Loc<N, F>> for Shift<T, N, F> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
64 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
65 | T: Mapping<Loc<N, F>, Codomain = V>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
66 | { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
67 | type Codomain = V; |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
68 | |
| 0 | 69 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
70 | fn apply<I: Instance<Loc<N, F>>>(&self, x: I) -> Self::Codomain { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
71 | self.base_fn.apply(x.own() - &self.shift) |
| 0 | 72 | } |
| 73 | } | |
| 74 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
75 | impl<'a, T, V: Space, F: Float, const N: usize> DifferentiableImpl<Loc<N, F>> for Shift<T, N, F> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
76 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
77 | T: DifferentiableMapping<Loc<N, F>, DerivativeDomain = V>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
78 | { |
|
47
a0db98c16ab5
Some Differentiable simplifications and clarifications
Tuomo Valkonen <tuomov@iki.fi>
parents:
30
diff
changeset
|
79 | type Derivative = V; |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
80 | |
|
30
9f2214c961cb
Implement Differentiable for Weighted and Shift
Tuomo Valkonen <tuomov@iki.fi>
parents:
15
diff
changeset
|
81 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
82 | fn differential_impl<I: Instance<Loc<N, F>>>(&self, x: I) -> Self::Derivative { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
83 | self.base_fn.differential(x.own() - &self.shift) |
|
30
9f2214c961cb
Implement Differentiable for Weighted and Shift
Tuomo Valkonen <tuomov@iki.fi>
parents:
15
diff
changeset
|
84 | } |
|
9f2214c961cb
Implement Differentiable for Weighted and Shift
Tuomo Valkonen <tuomov@iki.fi>
parents:
15
diff
changeset
|
85 | } |
|
9f2214c961cb
Implement Differentiable for Weighted and Shift
Tuomo Valkonen <tuomov@iki.fi>
parents:
15
diff
changeset
|
86 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
87 | impl<'a, T, F: Float, const N: usize> Support<N, F> for Shift<T, N, F> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
88 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
89 | T: Support<N, F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
90 | { |
| 0 | 91 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
92 | fn support_hint(&self) -> Cube<N, F> { |
| 0 | 93 | self.base_fn.support_hint().shift(&self.shift) |
| 94 | } | |
| 95 | ||
| 96 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
97 | fn in_support(&self, x: &Loc<N, F>) -> bool { |
| 0 | 98 | self.base_fn.in_support(&(x - &self.shift)) |
| 99 | } | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
100 | |
| 0 | 101 | // fn fully_in_support(&self, _cube : &Cube<F,N>) -> bool { |
| 102 | // //self.base_fn.fully_in_support(cube.shift(&vectorneg(self.shift))) | |
| 103 | // todo!("Not implemented, but not used at the moment") | |
| 104 | // } | |
| 105 | ||
| 106 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
107 | fn bisection_hint(&self, cube: &Cube<N, F>) -> [Option<F>; N] { |
| 0 | 108 | let base_hint = self.base_fn.bisection_hint(cube); |
| 109 | map2(base_hint, &self.shift, |h, s| h.map(|z| z + *s)) | |
| 110 | } | |
| 111 | } | |
| 112 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
113 | impl<'a, T, F: Float, const N: usize> GlobalAnalysis<F, Bounds<F>> for Shift<T, N, F> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
114 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
115 | T: LocalAnalysis<F, Bounds<F>, N>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
116 | { |
| 0 | 117 | #[inline] |
| 118 | fn global_analysis(&self) -> Bounds<F> { | |
| 119 | self.base_fn.global_analysis() | |
| 120 | } | |
| 121 | } | |
| 122 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
123 | impl<'a, T, F: Float, const N: usize> LocalAnalysis<F, Bounds<F>, N> for Shift<T, N, F> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
124 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
125 | T: LocalAnalysis<F, Bounds<F>, N>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
126 | { |
| 0 | 127 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
128 | fn local_analysis(&self, cube: &Cube<N, F>) -> Bounds<F> { |
| 0 | 129 | self.base_fn.local_analysis(&cube.shift(&(-self.shift))) |
| 130 | } | |
| 131 | } | |
| 132 | ||
| 133 | macro_rules! impl_shift_norm { | |
| 134 | ($($norm:ident)*) => { $( | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
135 | impl<'a, T, F : Float, const N : usize> Norm<$norm, F> for Shift<T, N, F> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
136 | where T : Norm<$norm, F> { |
| 0 | 137 | #[inline] |
| 138 | fn norm(&self, n : $norm) -> F { | |
| 139 | self.base_fn.norm(n) | |
| 140 | } | |
| 141 | } | |
| 142 | )* } | |
| 143 | } | |
| 144 | ||
| 145 | impl_shift_norm!(L1 L2 Linfinity); | |
| 146 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
147 | impl<'a, T, F: Float, C, const N: usize> Support<N, F> for Weighted<T, C> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
148 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
149 | T: Support<N, F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
150 | C: Constant<Type = F>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
151 | { |
| 0 | 152 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
153 | fn support_hint(&self) -> Cube<N, F> { |
| 0 | 154 | self.base_fn.support_hint() |
| 155 | } | |
| 156 | ||
| 157 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
158 | fn in_support(&self, x: &Loc<N, F>) -> bool { |
| 0 | 159 | self.base_fn.in_support(x) |
| 160 | } | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
161 | |
| 0 | 162 | // fn fully_in_support(&self, cube : &Cube<F,N>) -> bool { |
| 163 | // self.base_fn.fully_in_support(cube) | |
| 164 | // } | |
| 165 | ||
| 166 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
167 | fn bisection_hint(&self, cube: &Cube<N, F>) -> [Option<F>; N] { |
| 0 | 168 | self.base_fn.bisection_hint(cube) |
| 169 | } | |
| 170 | } | |
| 171 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
172 | impl<'a, T, F: Float, C> GlobalAnalysis<F, Bounds<F>> for Weighted<T, C> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
173 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
174 | T: GlobalAnalysis<F, Bounds<F>>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
175 | C: Constant<Type = F>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
176 | { |
| 0 | 177 | #[inline] |
| 178 | fn global_analysis(&self) -> Bounds<F> { | |
| 179 | let Bounds(lower, upper) = self.base_fn.global_analysis(); | |
|
8
4e09b7829b51
Multithreaded bisection tree operations
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
180 | debug_assert!(lower <= upper); |
| 0 | 181 | match self.weight.value() { |
| 182 | w if w < F::ZERO => Bounds(w * upper, w * lower), | |
| 183 | w => Bounds(w * lower, w * upper), | |
| 184 | } | |
| 185 | } | |
| 186 | } | |
| 187 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
188 | impl<'a, T, F: Float, C, const N: usize> LocalAnalysis<F, Bounds<F>, N> for Weighted<T, C> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
189 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
190 | T: LocalAnalysis<F, Bounds<F>, N>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
191 | C: Constant<Type = F>, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
192 | { |
| 0 | 193 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
194 | fn local_analysis(&self, cube: &Cube<N, F>) -> Bounds<F> { |
| 0 | 195 | let Bounds(lower, upper) = self.base_fn.local_analysis(cube); |
|
8
4e09b7829b51
Multithreaded bisection tree operations
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
196 | debug_assert!(lower <= upper); |
| 0 | 197 | match self.weight.value() { |
| 198 | w if w < F::ZERO => Bounds(w * upper, w * lower), | |
| 199 | w => Bounds(w * lower, w * upper), | |
| 200 | } | |
| 201 | } | |
| 202 | } | |
| 203 | ||
| 204 | macro_rules! make_weighted_scalarop_rhs { | |
| 205 | ($trait:ident, $fn:ident, $trait_assign:ident, $fn_assign:ident) => { | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
206 | impl<F: Float, T> std::ops::$trait_assign<F> for Weighted<T, F> { |
| 0 | 207 | #[inline] |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
208 | fn $fn_assign(&mut self, t: F) { |
| 0 | 209 | self.weight.$fn_assign(t); |
| 210 | } | |
| 211 | } | |
| 212 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
213 | impl<'a, F: Float, T> std::ops::$trait<F> for Weighted<T, F> { |
| 0 | 214 | type Output = Self; |
| 215 | #[inline] | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
216 | fn $fn(mut self, t: F) -> Self { |
| 0 | 217 | self.weight.$fn_assign(t); |
| 218 | self | |
| 219 | } | |
| 220 | } | |
| 221 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
222 | impl<'a, F: Float, T> std::ops::$trait<F> for &'a Weighted<T, F> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
223 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
224 | T: Clone, |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
225 | { |
| 0 | 226 | type Output = Weighted<T, F>; |
| 227 | #[inline] | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
228 | fn $fn(self, t: F) -> Self::Output { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
229 | Weighted { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
230 | weight: self.weight.$fn(t), |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
231 | base_fn: self.base_fn.clone(), |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
232 | } |
| 0 | 233 | } |
| 234 | } | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
235 | }; |
| 0 | 236 | } |
| 237 | ||
| 238 | make_weighted_scalarop_rhs!(Mul, mul, MulAssign, mul_assign); | |
| 239 | make_weighted_scalarop_rhs!(Div, div, DivAssign, div_assign); | |
| 240 | ||
| 241 | macro_rules! impl_weighted_norm { | |
| 242 | ($($norm:ident)*) => { $( | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
243 | impl<'a, T, F : Float> Norm<$norm, F> for Weighted<T,F> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
244 | where T : Norm<$norm, F> { |
| 0 | 245 | #[inline] |
| 246 | fn norm(&self, n : $norm) -> F { | |
| 247 | self.base_fn.norm(n) * self.weight.abs() | |
| 248 | } | |
| 249 | } | |
| 250 | )* } | |
| 251 | } | |
| 252 | ||
| 253 | impl_weighted_norm!(L1 L2 Linfinity); | |
| 254 | ||
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
255 | /// Normalisation of [`Support`] and [`Mapping`] to L¹ norm 1. |
| 5 | 256 | /// |
| 0 | 257 | /// Currently only scalar-valued functions are supported. |
| 258 | #[derive(Copy, Clone, Debug, Serialize, PartialEq)] | |
| 5 | 259 | pub struct Normalised<T>( |
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
260 | /// The base [`Support`] or [`Mapping`]. |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
261 | pub T, |
| 5 | 262 | ); |
| 0 | 263 | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
264 | impl<'a, T, F: Float, const N: usize> Mapping<Loc<N, F>> for Normalised<T> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
265 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
266 | T: Norm<L1, F> + Mapping<Loc<N, F>, Codomain = F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
267 | { |
|
59
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
268 | type Codomain = F; |
|
9226980e45a7
Significantly simplify Mapping / Apply through Instance
Tuomo Valkonen <tuomov@iki.fi>
parents:
47
diff
changeset
|
269 | |
| 0 | 270 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
271 | fn apply<I: Instance<Loc<N, F>>>(&self, x: I) -> Self::Codomain { |
| 0 | 272 | let w = self.0.norm(L1); |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
273 | if w == F::ZERO { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
274 | F::ZERO |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
275 | } else { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
276 | self.0.apply(x) / w |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
277 | } |
| 0 | 278 | } |
| 279 | } | |
| 280 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
281 | impl<'a, T, F: Float, const N: usize> Support<N, F> for Normalised<T> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
282 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
283 | T: Norm<L1, F> + Support<N, F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
284 | { |
| 0 | 285 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
286 | fn support_hint(&self) -> Cube<N, F> { |
| 0 | 287 | self.0.support_hint() |
| 288 | } | |
| 289 | ||
| 290 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
291 | fn in_support(&self, x: &Loc<N, F>) -> bool { |
| 0 | 292 | self.0.in_support(x) |
| 293 | } | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
294 | |
| 0 | 295 | // fn fully_in_support(&self, cube : &Cube<F,N>) -> bool { |
| 296 | // self.0.fully_in_support(cube) | |
| 297 | // } | |
| 298 | ||
| 299 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
300 | fn bisection_hint(&self, cube: &Cube<N, F>) -> [Option<F>; N] { |
| 0 | 301 | self.0.bisection_hint(cube) |
| 302 | } | |
| 303 | } | |
| 304 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
305 | impl<'a, T, F: Float> GlobalAnalysis<F, Bounds<F>> for Normalised<T> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
306 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
307 | T: Norm<L1, F> + GlobalAnalysis<F, Bounds<F>>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
308 | { |
| 0 | 309 | #[inline] |
| 310 | fn global_analysis(&self) -> Bounds<F> { | |
| 311 | let Bounds(lower, upper) = self.0.global_analysis(); | |
|
8
4e09b7829b51
Multithreaded bisection tree operations
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
312 | debug_assert!(lower <= upper); |
| 0 | 313 | let w = self.0.norm(L1); |
| 314 | debug_assert!(w >= F::ZERO); | |
| 315 | Bounds(w * lower, w * upper) | |
| 316 | } | |
| 317 | } | |
| 318 | ||
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
319 | impl<'a, T, F: Float, const N: usize> LocalAnalysis<F, Bounds<F>, N> for Normalised<T> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
320 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
321 | T: Norm<L1, F> + LocalAnalysis<F, Bounds<F>, N>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
322 | { |
| 0 | 323 | #[inline] |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
324 | fn local_analysis(&self, cube: &Cube<N, F>) -> Bounds<F> { |
| 0 | 325 | let Bounds(lower, upper) = self.0.local_analysis(cube); |
|
8
4e09b7829b51
Multithreaded bisection tree operations
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
326 | debug_assert!(lower <= upper); |
| 0 | 327 | let w = self.0.norm(L1); |
| 328 | debug_assert!(w >= F::ZERO); | |
| 329 | Bounds(w * lower, w * upper) | |
| 330 | } | |
| 331 | } | |
| 332 | ||
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
333 | impl<'a, T, F: Float> Norm<L1, F> for Normalised<T> |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
334 | where |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
335 | T: Norm<L1, F>, |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
336 | { |
| 0 | 337 | #[inline] |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
338 | fn norm(&self, _: L1) -> F { |
| 0 | 339 | let w = self.0.norm(L1); |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
340 | if w == F::ZERO { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
341 | F::ZERO |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
342 | } else { |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
343 | F::ONE |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
344 | } |
| 0 | 345 | } |
| 346 | } | |
| 347 | ||
| 348 | macro_rules! impl_normalised_norm { | |
| 349 | ($($norm:ident)*) => { $( | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
350 | impl<'a, T, F : Float> Norm<$norm, F> for Normalised<T> |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
351 | where T : Norm<$norm, F> + Norm<L1, F> { |
| 0 | 352 | #[inline] |
| 353 | fn norm(&self, n : $norm) -> F { | |
| 354 | let w = self.0.norm(L1); | |
| 355 | if w == F::ZERO { F::ZERO } else { self.0.norm(n) / w } | |
| 356 | } | |
| 357 | } | |
| 358 | )* } | |
| 359 | } | |
| 360 | ||
| 361 | impl_normalised_norm!(L2 Linfinity); | |
| 362 | ||
| 363 | /* | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
364 | impl<F : Num, S : Support< N, F>, const N : usize> LocalAnalysis<F, NullAggregator, N> for S { |
|
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
365 | fn local_analysis(&self, _cube : &Cube<N, F>) -> NullAggregator { NullAggregator } |
| 0 | 366 | } |
| 367 | ||
| 368 | impl<F : Float, S : Bounded<F>, const N : usize> LocalAnalysis<F, Bounds<F>, N> for S { | |
| 369 | #[inline] | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
370 | fn local_analysis(&self, cube : &Cube<N, F>) -> Bounds<F> { |
| 0 | 371 | self.bounds(cube) |
| 372 | } | |
| 373 | }*/ | |
| 374 | ||
| 5 | 375 | /// Generator of [`Support`]-implementing component functions based on low storage requirement |
| 376 | /// [ids][`Self::Id`]. | |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
377 | pub trait SupportGenerator<const N: usize, F: Float = f64>: |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
378 | MulAssign<F> + DivAssign<F> + Neg<Output = Self> + Clone + Sync + Send + 'static |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
379 | { |
| 5 | 380 | /// The identification type |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
381 | type Id: 'static + Copy; |
|
75
e9f4550cfa18
Fix out-of-date references in doc comments
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
382 | /// The type of the [`Support`] (often also a [`Mapping`]). |
|
124
6aa955ad8122
Transpose loc parameters to allow f64 defaults
Tuomo Valkonen <tuomov@iki.fi>
parents:
97
diff
changeset
|
383 | type SupportType: 'static + Support<N, F>; |
| 5 | 384 | /// An iterator over all the [`Support`]s of the generator. |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
385 | type AllDataIter<'a>: Iterator<Item = (Self::Id, Self::SupportType)> |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
386 | where |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
387 | Self: 'a; |
| 0 | 388 | |
| 5 | 389 | /// Returns the component identified by `id`. |
| 390 | /// | |
| 391 | /// Panics if `id` is an invalid identifier. | |
|
96
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
392 | fn support_for(&self, id: Self::Id) -> Self::SupportType; |
|
962c8e346ab9
Allow Zed to reindent btfn.rs, support.rs, aggregator.rs, and bt.rs.
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
393 | |
| 5 | 394 | /// Returns the number of different components in this generator. |
| 0 | 395 | fn support_count(&self) -> usize; |
| 396 | ||
| 5 | 397 | /// Returns an iterator over all pairs of `(id, support)`. |
| 0 | 398 | fn all_data(&self) -> Self::AllDataIter<'_>; |
| 399 | } |