Finish rotmg to the BLAS reference (C8 part 3)#20
Merged
Conversation
srotmg was a faithful translation of the reference SROTMG algorithm but unusable: it had no rndMode parameter, computed gamsq as an integer multiply of two float bit-patterns (0x45800000 * 0x45800000 -> garbage rather than 2^24), compared float32_t structs against bare integer constants, and had a paren-less `else if f32_eq(...)`. Rewrite srotmg cleanly against the Netlib reference with correct SoftFloat usage and the right rescaling constants (gam=4096, gamsq=2^24, rgam=2^-12, rgamsq=2^-24). Generate drotmg with the float64 bit patterns of those constants. For hrotmg the reference constants do not fit: gamsq=2^24 exceeds float16's max (~65504). Use a reduced-but-consistent band instead (gam=16, gamsq=256, rgam=1/16, rgamsq=1/256), documented in the source. test_rotmg.c: srotmg(1,1,1,1) -> d1=d2=0.5, x1=2, flag=1, h11=h22=1; the d2*y1==0 -> flag=-2 path; and drotmg(1,1,1,1). 180/180 tests pass. This completes the rotation family (rot/rotg/rotm/rotmg, all precisions). sdsdot/hsdot remain. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the rotation family (rot/rotg/rotm/rotmg, all precisions).
srotmgwas a faithful translation of the reference algorithm but unusable: norndMode;gamsqcomputed as an integer multiply of two float bit-patterns (0x45800000 * 0x45800000→ garbage, not2²⁴); float32_t structs compared against bare integers; a paren-lesselse if f32_eq(...).srotmgagainst Netlib with correct SoftFloat usage and the right rescale constants (gam=4096, gamsq=2²⁴, rgam=2⁻¹², rgamsq=2⁻²⁴).drotmgwith the float64 bit patterns.hrotmg: the referencegamsq=2²⁴exceeds float16's max (~65504), so it uses a reduced consistent band (gam=16, gamsq=256, …), documented in the source.test_rotmg.c:srotmg(1,1,1,1) → d1=d2=0.5, x1=2, flag=1, h11=h22=1; thed2·y1==0 → flag=-2path;drotmg(1,1,1,1). 180/180.sdsdot/hsdotare the only remaining unfinished Level-1 routines.🤖 Generated with Claude Code