Skip to content

Commit e28359c

Browse files
authored
Merge pull request #141 from JuliaSymbolics/pow-rework
Convert `inv` to literal pow
2 parents 30e13a5 + b6484dd commit e28359c

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/abstractalgebra.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ let
6565
@acrule(~x::ismpoly * ~y::ismpoly => ~x * ~y)
6666
@rule(*(~x) => ~x)
6767
@rule((~x::ismpoly)^(~a::isnonnegint) => (~x)^(~a))]
68-
MPOLY_CLEANUP = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_preprocess))))
68+
global const MPOLY_CLEANUP = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_preprocess))))
6969
MPOLY_MAKER = Fixpoint(Postwalk(PassThrough(RestartedChain(mpoly_rules))))
7070

71-
global MPOLY_CLEANUP
72-
7371
global to_mpoly
7472
function to_mpoly(t, dicts=_dicts())
7573
# term2sym is only used to assign the same

src/methods.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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]
1+
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]
22

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

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

138+
# Specially handle inv
139+
Base.inv(x::Symbolic) = Base.:^(x, -1)

src/simplify_rules.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ let
3939
@rule((((~x)^(~p::isliteral(Integer)))^(~q::isliteral(Integer))) => (~x)^((~p)*(~q)))
4040
@rule(^(~x, ~z::_iszero) => 1)
4141
@rule(^(~x, ~z::_isone) => ~x)
42+
@rule(inv(~x) => ~x ^ -1)
4243
]
4344

4445
ASSORTED_RULES = [

0 commit comments

Comments
 (0)