From 388b2fff32394cb0eccc023433b1735e695d9401 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 22 Sep 2023 13:40:06 -0400 Subject: [PATCH 1/3] edit --- ext/SymEngineSymbolicUtilsExt.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/SymEngineSymbolicUtilsExt.jl b/ext/SymEngineSymbolicUtilsExt.jl index e6543cc..6dc6f54 100644 --- a/ext/SymEngineSymbolicUtilsExt.jl +++ b/ext/SymEngineSymbolicUtilsExt.jl @@ -37,6 +37,7 @@ Check if x represents an expression tree. If returns true, it will be assumed th function SymbolicUtils.istree(x::SymEngine.SymbolicType) cls = SymEngine.get_symengine_class(x) cls == :Symbol && return false + cls == :Constant && return false any(==(cls), SymEngine.number_types) && return false return true end From fd24998f8e93db349431067ea0e09a73008ff935 Mon Sep 17 00:00:00 2001 From: jverzani Date: Mon, 25 Sep 2023 10:52:36 -0400 Subject: [PATCH 2/3] update for SymbolicUtils v1.4 --- Project.toml | 1 + ext/SymEngineSymbolicUtilsExt.jl | 31 +++++++++---------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Project.toml b/Project.toml index 0e2e4ef..ef72b71 100644 --- a/Project.toml +++ b/Project.toml @@ -22,6 +22,7 @@ Compat = "0.63.0, 1, 2, 3, 4" RecipesBase = "0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0" SpecialFunctions = "0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 1, 2" SymEngine_jll = "0.9, 0.10" +SymbolicUtils = "1.4" julia = "1.6" [extras] diff --git a/ext/SymEngineSymbolicUtilsExt.jl b/ext/SymEngineSymbolicUtilsExt.jl index 6dc6f54..d5ab754 100644 --- a/ext/SymEngineSymbolicUtilsExt.jl +++ b/ext/SymEngineSymbolicUtilsExt.jl @@ -73,32 +73,19 @@ end # Needed for some simplification routines # a total order <ₑ -import SymbolicUtils: <ₑ, isterm, isadd, ismul, issym, cmp_mul_adds, cmp_term_term +import SymbolicUtils: <ₑ, isterm, isadd, ismul, issym, get_degrees, monomial_lt, _arglen function SymbolicUtils.:<ₑ(a::SymEngine.Basic, b::SymEngine.Basic) - if isterm(a) && !isterm(b) - return false - elseif isterm(b) && !isterm(a) - return true - elseif (isadd(a) || ismul(a)) && (isadd(b) || ismul(b)) - return cmp_mul_adds(a, b) - elseif issym(a) && issym(b) - nameof(a) < nameof(b) - elseif !istree(a) && !istree(b) - T = typeof(a) - S = typeof(b) - if T == S - is_number(a) && is_number(b) && return N(a) < N(b) - return hash(a) < hash(b) + da, db = get_degrees(a), get_degrees(b) + fw = monomial_lt(da, db) + bw = monomial_lt(db, da) + if fw === bw && !isequal(a, b) + if _arglen(a) == _arglen(b) + return (operation(a), arguments(a)...,) <ₑ (operation(b), arguments(b)...,) else - return name(T) < nameof(S) + return _arglen(a) < _arglen(b) end - #return T===S ? (T <: Number ? isless(a, b) : hash(a) < hash(b)) : nameof(T) < nameof(S) - elseif istree(b) && !istree(a) - return true - elseif istree(a) && istree(b) - return cmp_term_term(a,b) else - return !(b <ₑ a) + return fw end end From a34c325ce2bc270ddc27f1318e72979dc4e46ccd Mon Sep 17 00:00:00 2001 From: jverzani Date: Mon, 25 Sep 2023 11:02:11 -0400 Subject: [PATCH 3/3] run doctest(SymEngine, fix=true) --- docs/Project.toml | 3 +++ docs/src/basicUsage.md | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 4e5de6a..44199c0 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,3 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" SymEngine = "123dc426-2d89-5057-bbad-38513e3affd8" + +[compat] +Documenter = "1" \ No newline at end of file diff --git a/docs/src/basicUsage.md b/docs/src/basicUsage.md index 98b3d54..5def068 100644 --- a/docs/src/basicUsage.md +++ b/docs/src/basicUsage.md @@ -43,7 +43,7 @@ Vectors can be defined through list comprehension and string interpolation. julia> using SymEngine julia> [symbols("α_$i") for i in 1:3] -3-element Array{Basic,1}: +3-element Vector{Basic}: α_1 α_2 α_3 @@ -56,7 +56,7 @@ In an analogous manner, matrices are declared with a combination of string inter julia> using SymEngine julia> W = [symbols("W_$i$j") for i in 1:3, j in 1:4] -3×4 Array{Basic,2}: +3×4 Matrix{Basic}: W_11 W_12 W_13 W_14 W_21 W_22 W_23 W_24 W_31 W_32 W_33 W_34 @@ -70,13 +70,13 @@ Consider the canonical example of **matrix vector multiplication**. julia> using SymEngine julia> W = [symbols("W_$i$j") for i in 1:3, j in 1:4] -3×4 Array{Basic,2}: +3×4 Matrix{Basic}: W_11 W_12 W_13 W_14 W_21 W_22 W_23 W_24 W_31 W_32 W_33 W_34 julia> W*[1.0, 2.0, 3.0, 4.0] -3-element Array{Basic,1}: +3-element Vector{Basic}: 1.0*W_11 + 2.0*W_12 + 3.0*W_13 + 4.0*W_14 1.0*W_21 + 2.0*W_22 + 3.0*W_23 + 4.0*W_24 1.0*W_31 + 2.0*W_32 + 3.0*W_33 + 4.0*W_34