Skip to content

Commit

Permalink
Add hash(::TropicalSemiringElem)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 11, 2023
1 parent c35eb7d commit 441a5a9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AlgebraicGeometry/TropicalGeometry/semiring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Oscar.isone(x::TropicalSemiringElem) = !isinf(x) && iszero(data(x))

################################################################################
#
# Equality
# Equality and hash
#
################################################################################

Expand All @@ -237,6 +237,15 @@ function Base.:(==)(x::TropicalSemiringElem, y::TropicalSemiringElem)
return data(x) == data(y)
end

function Base.hash(x::TropicalSemiringElem, h::UInt)
b = 0x4df38853cc07aa27 % UInt
h = hash(isinf(x), h)
if !isinf(x)
h = hash(data(x), h)
end
return xor(h, b)
end

################################################################################
#
# Comparison
Expand Down

0 comments on commit 441a5a9

Please sign in to comment.