1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//! Policy-neutral matrix rewrites and arithmetic provenance primitives.
//!
//! These leaves describe arithmetic that is shared by the reference writer
//! and independent proof without carrying a scale operation, expected value,
//! tolerance decision, connector product, or proof result.
use ;
/// `B' = U B U^-1` for a uniform `U = scale(q)`: the translation column
/// scales by `q`; the linear part is unchanged.
pub
/// `scale(k) * M`: every output row (x/y/z, not the homogeneous row) scales
/// by `k`, which is what left-multiplying by a uniform scale does to both
/// the linear part and the translation column.
pub
/// The largest absolute component difference between two matrices.
pub
/// The largest magnitude any entry of `a * b` is summed from:
/// `max over (i, j) of sum over k of abs(a_ik) * abs(b_kj)`.
///
/// This is the magnitude an `f32` `a * b` rounds against, and it is what
/// [`super::ScaleTolerancePolicy::f32_rounding_ulps`] is counted in for the
/// obligations that compare such a product. [`matrix_magnitude`] of the
/// product itself is not: a rotation makes `W * B` near-identity — max entry
/// `1.0` — while its translation column was the difference of two entries of
/// magnitude `abs(W)`, and the error that cancellation leaves behind is
/// `abs(W)`'s ulp, not `1.0`'s.
///
/// Nor is `matrix_magnitude(a) * matrix_magnitude(b)`, which is the same
/// quantity with the sum over `k` replaced by a product of two independent
/// maxima. On a `W * B` whose largest entries are both in the translation
/// column that overstates by the ratio between them: on a rotating rig at
/// factor `3190` it reads `7.6e6` where the arithmetic ran on `6.4e3`, and a
/// tolerance derived from it would accept a matrix that is entirely wrong.
pub
/// [`product_operand_magnitude`] recomputed as a scalar `f64` fold, for the
/// operands whose `f32` sums overflow.
///
/// These sums are the *operands'* magnitudes, not the product's, so they run
/// past `f32::MAX` while `a * b` is still finite — the cancellation that
/// makes `W * B` near-identity is exactly what removes the magnitude from the
/// result. Sweeping 2_000_000 random rig-shaped `W` / `B` pairs found 87 such
/// pairs, the smallest with an operand entry of `7.04e37`. Without this
/// fallback each one made [`super::proof::SkinSlot::rounding_magnitude`] infinite,
/// which makes the tolerance derived from it infinite, which
/// [`super::proof::check_residual`] refuses — a *correct* candidate rejected with
/// `tolerance: inf`. `SkinMatrix` reaches it from the joint transforms
/// alone, with no unusual geometry involved.
///
/// The fold cannot overflow in turn, for any `a` and `b` this proof can
/// reach. Each term is a product of two `f32` magnitudes, at most
/// `f32::MAX^2 = 1.16e77`, and each sum has four of them: `4.63e77`, a
/// hundred and fifty decades below `f64::MAX`. So the case is removed rather
/// than moved, and it needs no domain caveat of its own.
/// The rounding base of the translation column in `parent_world * local`.
///
/// For each spatial row, `s` is the binary64 absolute sum of the three new
/// linear/local-translation products and `p` is the absolute carried parent
/// translation. The row contributes
/// `s + min(max(p, MIN_POSITIVE), s / EPSILON)`: `EPSILON * s` provisions the
/// local dot product, while the capped second term provisions the smaller of
/// one parent-scale ulp and losing the whole new contribution. The minimum
/// normal floor also covers subnormal product rounding. Zero links still
/// contribute zero, and underflowed links carry only their vanishing `s`
/// rather than charging the translated parent again.
///
/// [`product_operand_magnitude`] for one column, and it exists for the same
/// reason one column further up the chain. That function reads the *already
/// composed* `W`, whose translation column has already lost whatever its own
/// parent chain cancelled: a joint whose local offset points back along its
/// parent's world translation leaves `W` with a small translation that was
/// summed from two large terms, and `abs(W) * abs(B)` cannot see terms that
/// are no longer in `W`. Composing `W * B` then carries that lost magnitude's
/// rounding error into a near-identity product, and a tolerance derived from
/// `abs(W) * abs(B)` alone refuses the correct candidate — measured at up to
/// `41` binary32 ulps of that base over a million correct candidates, against
/// `2.4` once this term is included.
///
/// The homogeneous output row is deliberately excluded because it is not a
/// spatial translation component. For validated affine operands its linear
/// entries are zero, so the shipped `contribution / EPSILON` cap would already
/// make its contribution zero. Keeping the spatial range explicit preserves
/// the quantity's unit semantics and prevents a non-affine bottom row from
/// entering provenance if upstream validation regresses.
///
/// Only the translation column needs it. A world linear part is a product of
/// rotations and uniform scales, and while an individual entry of that
/// product can cancel to near zero, `product_operand_magnitude` already sums
/// over the inner index — so the terms that cancelled are still in its sum.
/// The translation column is the one place a *previous* composition's
/// cancellation is carried forward as an operand.
pub
/// The magnitude `matrix * column` is summed from:
/// `max over i of sum over k of abs(matrix_ik) * abs(column_k)`.
///
/// [`product_operand_magnitude`] for one column, and the quantity the bounds
/// path needs when a composed `W * B` transforms a vertex position.
///
/// `absolute` is [`mat4_abs`] of the matrix, taken by the caller rather than
/// here. The skinned-bounds caller runs this once per weighted vertex per slot
/// — the hottest loop in this proof — against a matrix that is constant across
/// the whole primitive, so recomputing sixteen `abs` per vertex would be work
/// the slot already did once.
pub
/// [`column_operand_magnitude`] recomputed as a scalar `f64` fold, for the
/// operands whose `f32` sums overflow.
///
/// Cannot overflow in turn, for [`product_operand_magnitude_f64`]'s reason:
/// four terms, each a product of two `f32` magnitudes, is at most `4.63e77`.
/// `abs` applied to every component.
pub
/// The largest entry of an already non-negative matrix.
pub
/// The largest absolute component of a matrix.
pub