Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert inv to literal pow #141

Merged
merged 4 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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