feat(v4.0.0): full-range UM* under plain F18 +* (D-3)
UM* as first written in DECOMPOSITION.md section 4 was exact only while u1 <= 2^(n-2): plain +* loses the carry out of T and its shift keeps T's sign bit, so the loop is exact only while S and T stay in [-2^(n-2), 2^(n-2)). The rewrite multiplies by s = u1 2/, which always lies in that range, starting T at t0 = u2 2/ when u1 is odd, so the loop yields hi:lo = t0 + s*u2 exactly. Then u1*u2 = 2*(hi:lo) + c_lo + c_hi*2^n c_lo = u1 & u2 & 1 c_hi = (u1<0 ? u2 : 0) + (u1 odd and u2<0 ? 1 : 0) restores the halved-away bits and the unsigned reading of both top bits. test_foundation.c runs the new definition against v4_umul over every pair of the edge vectors plus 20000 pseudo-random pairs, at 32- and 64-bit cells, optimised and under ASan+UBSan. The two pinned failing cases are now ordinary exactness checks. Two hand mutations of the correction step each fail more than 10000 checks at both widths. DECOMPOSITION.md: section 4 UM* replaced, D-3 ruling text updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
067f317c47
commit
9a391eb0ad
@@ -1,6 +1,7 @@
|
||||
/* umul.h -- unsigned multiply fixing UM* under D-3 constraints.
|
||||
*
|
||||
* DECOMPOSITION.md line 205-207: "NEEDS REVISION: written for the carry-keeping
|
||||
* DECOMPOSITION.md section 4 first said of UM* (since rewritten to be exact over
|
||||
* the full range; see test_foundation.c): "NEEDS REVISION: written for the carry-keeping
|
||||
* +* that D-3 rejected. With plain F18 +* the carry out of T is lost, so this
|
||||
* is only correct when the partial sums never overflow T (operands below 2^31).
|
||||
* A full-range UM* needs a correction step; to be rewritten and proven on the
|
||||
|
||||
Reference in New Issue
Block a user