Skip to content

Commit

Permalink
Merge pull request #141 from JuliaSymbolics/pow-rework
Browse files Browse the repository at this point in the history
Convert `inv` to literal pow
  • Loading branch information
shashi authored Nov 19, 2020
2 parents 30e13a5 + b6484dd commit e28359c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/abstractalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ let
@acrule(~x::ismpoly * ~y::ismpoly => ~x * ~y)
@rule(*(~x) => ~x)
@rule((~x::ismpoly)^(~a::isnonnegint) => (~x)^(~a))]
MPOLY_CLEANUP = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_preprocess))))
global const MPOLY_CLEANUP = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_preprocess))))
MPOLY_MAKER = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_rules))))

global MPOLY_CLEANUP

global to_mpoly
function to_mpoly(t, dicts=_dicts())
# term2sym is only used to assign the same
Expand Down
4 changes: 3 additions & 1 deletion src/methods.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const monadic = [deg2rad, rad2deg, transpose, -, conj, asind, log1p, acsch, acos, asec, acosh, acsc, cscd, log, tand, log10, csch, asinh, abs2, cosh, sin, cos, atan, cospi, cbrt, acosd, acoth, inv, acotd, asecd, exp, acot, sqrt, sind, sinpi, asech, log2, tan, exp10, sech, coth, asin, cotd, cosd, sinh, abs, csc, tanh, secd, atand, sec, acscd, cot, exp2, expm1, atanh, real]
const monadic = [deg2rad, rad2deg, transpose, -, conj, asind, log1p, acsch, acos, asec, acosh, acsc, cscd, log, tand, log10, csch, asinh, abs2, cosh, sin, cos, atan, cospi, cbrt, acosd, acoth, acotd, asecd, exp, acot, sqrt, sind, sinpi, asech, log2, tan, exp10, sech, coth, asin, cotd, cosd, sinh, abs, csc, tanh, secd, atand, sec, acscd, cot, exp2, expm1, atanh, real]

const diadic = [+, -, max, min, *, /, \, hypot, atan, mod, rem, ^, copysign]

Expand Down Expand Up @@ -135,3 +135,5 @@ function cond(_if::Symbolic{Bool}, _then, _else)
Term{Union{symtype(_then), symtype(_else)}}(cond, Any[_if, _then, _else])
end

# Specially handle inv
Base.inv(x::Symbolic) = Base.:^(x, -1)
1 change: 1 addition & 0 deletions src/simplify_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let
@rule((((~x)^(~p::isliteral(Integer)))^(~q::isliteral(Integer))) => (~x)^((~p)*(~q)))
@rule(^(~x, ~z::_iszero) => 1)
@rule(^(~x, ~z::_isone) => ~x)
@rule(inv(~x) => ~x ^ -1)
]

ASSORTED_RULES = [
Expand Down

0 comments on commit e28359c

Please sign in to comment.