Skip to content

fix: enable runtime usage of inverse function by using compile-time unit extraction#726

Merged
mpusz merged 3 commits intompusz:masterfrom
rothmichaels:fix/optimal-inverse-runtime
Dec 21, 2025
Merged

fix: enable runtime usage of inverse function by using compile-time unit extraction#726
mpusz merged 3 commits intompusz:masterfrom
rothmichaels:fix/optimal-inverse-runtime

Conversation

@rothmichaels
Copy link
Copy Markdown
Contributor

Replace runtime unit access (q.unit) with compile-time type extraction (get_unit(R)) in the inverse function implementation. This prevents the function from becoming an immediate function when consteval unit operators are used, allowing inverse to work with runtime variables.

Key changes:

  • math.h: Use get_unit(R) instead of q.unit in both code paths
  • test: Add comprehensive runtime inverse tests

This surgical fix preserves maximum compile-time optimization while enabling DSP applications that need runtime inverse calculations.

Fixes compilation error with Clang:
"call to immediate function 'inverse' is not a constant expression"

🤖 Generated with Claude Code

@rothmichaels rothmichaels force-pushed the fix/optimal-inverse-runtime branch 2 times, most recently from b6f46a7 to 45754e7 Compare October 1, 2025 19:13
@mpusz
Copy link
Copy Markdown
Owner

mpusz commented Nov 5, 2025

Is this fix still needed?

…nit extraction

Replace runtime unit access (q.unit) with compile-time type extraction
(get_unit(R)) in the inverse function implementation. This prevents the
function from becoming an immediate function when consteval unit operators
are used, allowing inverse to work with runtime variables.

Key changes:
- math.h: Use get_unit(R) instead of q.unit in both code paths
- test: Add comprehensive runtime inverse tests

This surgical fix preserves maximum compile-time optimization while
enabling DSP applications that need runtime inverse calculations.

Fixes compilation error with Clang:
"call to immediate function 'inverse' is not a constant expression"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rothmichaels rothmichaels force-pushed the fix/optimal-inverse-runtime branch from 45754e7 to 507b2db Compare November 11, 2025 09:51
@rothmichaels
Copy link
Copy Markdown
Contributor Author

rothmichaels commented Nov 11, 2025

Is this fix still needed?

Yes this is still needed. @mpusz do you think this looks good to merge?

(I didn't mean to close the PR just now — I hit the wrong button)

@rothmichaels rothmichaels reopened this Nov 11, 2025
mpusz added a commit that referenced this pull request Dec 20, 2025
mpusz added a commit that referenced this pull request Dec 20, 2025
@mpusz mpusz merged commit 1bfe034 into mpusz:master Dec 21, 2025
85 checks passed
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.

2 participants