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

Use hashes instead of gensym id in PolyVar #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 2 deletions src/comp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ 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)
Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(x.name, y.name)

# Comparison of Monomial

Expand Down
7 changes: 2 additions & 5 deletions src/var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down