Repository navigation
Lower fractional and integer powers correctly in symstr and interstate edges - #2764
Draft
ThrudPrimrose wants to merge 7 commits into
Draft
ThrudPrimrose wants to merge 7 commits into
ThrudPrimrose wants to merge 7 commits into
Conversation
sqrt(M) printed as pow(M, 1/2), which is pow(M, 0) in C++: the square-root check parsed the printed exponent. A rational exponent now prints as a floating quotient, and an integer power's product is parenthesized, since x / N**2 printed as x/(N) * (N), i.e. x. Ported from extended.
A float or half base keeps a float pow instead of promoting to double; an integer base gets a float exponent and std::pow's double result.
… integral base Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lic exponents A p/q exponent is C++ integer division in symstr (M**(N/3), M**(1/N)) and in interstate assignments lowered by cppunparse (M**(1/3) ran as M**0). Both now emit dace::math::pow(base, p, q), which divides in the base's floating type (double for an integral base) and returns that type. sympy_divide_fix leaves non-integer exponents alone, and cppunparse no longer calls float(None) on a negated non-constant exponent.
ThrudPrimrose
marked this pull request as draft
October 29, 2026 07:26
…des in the computation type sympy_divide_fix replaced every quotient equal to one inside a fractional exponent, so in M**(N/3) + N/3 the outer N/3 lost its floor. It now rewrites bottom-up, one occurrence at a time. dace::math::pow(a, p, q) divided p and q in the base's type, so a half base overflowed (pow(h, 100000, 100000) was NaN); the quotient is now computed in float for a half.
…to fix-sympy-cpp-rational-power # Conflicts: # dace/runtime/include/dace/math.h # dace/symbolic.py # tests/runtime_math_test.py # tests/symbolic_roundtrip_test.py
ThrudPrimrose
added a commit
that referenced
this pull request
Oct 29, 2026
Extended's own rational-power lowering stays; the PR's denominator-power test joins it.
This branch has not been deployed
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.
sqrt(M),M**(1/3)andM**(N/3)printed C++ integer-division exponents (pow(M, 1/2)ispow(M, 0)), insymstrand in interstate assignments throughcppunparse, andx / N**2printed asx/(N) * (N). Fractional exponents now lower todace::math::pow(base, p, q), which divides in float for a half base, double for an integer base and the base's own type otherwise and returns the base's type (double for an integer base), while equal quotients outside the exponent stay floored, with printer, compile and end-to-end tests.