Skip to content

Commit 4d5a4d6

Browse files
fix: fix handling of negative coefficient exponent
1 parent 3bc17c9 commit 4d5a4d6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/types.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,9 +2734,14 @@ function ^(a::BasicSymbolic{T}, b) where {T <: Union{SymReal, SafeReal}}
27342734
BSImpl.AddMul(; coeff, dict, variant, shape, type) && if variant == AddMulVariant.MUL end => begin
27352735
if coeff isa Real && coeff < 0 && !isinteger(b)
27362736
coeff = (-coeff) ^ b
2737-
newmul = BSImpl.AddMul{T}(1, dict, variant; shape, type)
2738-
newpow = Term{T}(^, ArgsT{T}((newmul, b)); shape, type)
2739-
return mul_worker(T, (coeff, newpow))
2737+
newmul = BSImpl.AddMul{T}(-1, dict, variant; shape, type)
2738+
# newpow = Term{T}(^, ArgsT{T}((newmul, b)); shape, type)
2739+
if _isone(coeff)
2740+
return Term{T}(^, ArgsT{T}((newmul, b)); shape, type)
2741+
else
2742+
return BSImpl.AddMul{T}(coeff, ACDict{T}(newmul => b), AddMulVariant.MUL; shape, type)
2743+
end
2744+
# return mul_worker(T, (coeff, newpow))
27402745
else
27412746
coeff = coeff ^ b
27422747
dict = copy(dict)

0 commit comments

Comments
 (0)