Skip to content

Finish rotmg to the BLAS reference (C8 part 3)#20

Merged
sigilante merged 1 commit into
masterfrom
fix/finish-rotmg
May 30, 2026
Merged

Finish rotmg to the BLAS reference (C8 part 3)#20
sigilante merged 1 commit into
masterfrom
fix/finish-rotmg

Conversation

@sigilante
Copy link
Copy Markdown
Collaborator

Completes the rotation family (rot/rotg/rotm/rotmg, all precisions).

srotmg was a faithful translation of the reference algorithm but unusable: no rndMode; gamsq computed as an integer multiply of two float bit-patterns (0x45800000 * 0x45800000 → garbage, not 2²⁴); float32_t structs compared against bare integers; a paren-less else if f32_eq(...).

  • Rewrote srotmg against Netlib with correct SoftFloat usage and the right rescale constants (gam=4096, gamsq=2²⁴, rgam=2⁻¹², rgamsq=2⁻²⁴).
  • Generated drotmg with the float64 bit patterns.
  • hrotmg: the reference gamsq=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; the d2·y1==0 → flag=-2 path; drotmg(1,1,1,1). 180/180.

sdsdot/hsdot are the only remaining unfinished Level-1 routines.

🤖 Generated with Claude Code

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>
@sigilante sigilante merged commit a4a4c5c into master May 30, 2026
1 check passed
@sigilante sigilante deleted the fix/finish-rotmg branch May 30, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant