Skip to content

Commit 074b70d

Browse files
committed
fix power of negative exponent
1 parent 8b89562 commit 074b70d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/direct.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ function simplified_expr(O::Operation)
4343
isempty(O.args) && return O.op.name
4444
return Expr(:call, Symbol(O.op), simplified_expr.(O.args)...)
4545
end
46+
if O.op === (^)
47+
if length(O.args) > 1 && O.args[2] isa Constant && O.args[2].value < 0
48+
return Expr(:call, :^, Expr(:call, :inv, simplified_expr(O.args[1])), -(O.args[2].value))
49+
end
50+
end
4651
return Expr(:call, Symbol(O.op), simplified_expr.(O.args)...)
4752
end
4853

0 commit comments

Comments
 (0)