From 1b6fcb6ec380e36b4c5ce6001989039984affc89 Mon Sep 17 00:00:00 2001 From: Sascha Timme Date: Thu, 21 Feb 2019 13:36:58 +0100 Subject: [PATCH 1/2] Use hashes instead of gensym id in PolyVar --- src/comp.jl | 2 +- src/var.jl | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/comp.jl b/src/comp.jl index b586781..31ef3be 100644 --- a/src/comp.jl +++ b/src/comp.jl @@ -22,7 +22,7 @@ end # Comparison of PolyVar function (==)(x::PolyVar{C}, y::PolyVar{C}) where C - x.id == y.id + x.id == y.id && x.name == y.name end Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(y.id, x.id) diff --git a/src/var.jl b/src/var.jl index dcad083..6f424fb 100644 --- a/src/var.jl +++ b/src/var.jl @@ -42,14 +42,11 @@ macro ncpolyvar(args...) end struct PolyVar{C} <: AbstractVariable - id::Int + id::UInt name::String function PolyVar{C}(name::AbstractString) where {C} - # gensym returns something like Symbol("##42") - # we first remove "##" and then parse it into an Int - id = parse(Int, string(gensym())[3:end]) - new(id, convert(String, name)) + new(hash(name), convert(String, name)) end end From e5a312e1e319be85c821f379512c3fcf9a7c81b2 Mon Sep 17 00:00:00 2001 From: Sascha Timme Date: Thu, 21 Feb 2019 14:52:21 +0100 Subject: [PATCH 2/2] Use alphabetic ordering for PolyVars --- src/comp.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/comp.jl b/src/comp.jl index 31ef3be..e0db7a4 100644 --- a/src/comp.jl +++ b/src/comp.jl @@ -25,7 +25,7 @@ function (==)(x::PolyVar{C}, y::PolyVar{C}) where C x.id == y.id && x.name == y.name end -Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(y.id, x.id) +Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(x.name, y.name) # Comparison of Monomial