Skip to content

Commit

Permalink
Update == and hash for toric types
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 22, 2023
1 parent a295d90 commit a7d55ef
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ end
####################################################

function Base.:(==)(ac1::RationalEquivalenceClass, ac2::RationalEquivalenceClass)
return toric_variety(ac1) === toric_variety(ac2) && iszero(polynomial(ac1-ac2))
return toric_variety(ac1) === toric_variety(ac2) && polynomial(ac1) == polynomial(ac2)
end

function Base.hash(ac::RationalEquivalenceClass, h::UInt)
b = 0xb5d4ac6b9084eb6e % UInt
h = hash(toric_variety(ac), h)
return xor(h, b)
b = 0xb5d4ac6b9084eb6e % UInt
h = hash(toric_variety(ac), h)
h = hash(polynomial(ac), h)
return xor(h, b)
end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,15 @@ Base.:^(cc::CohomologyClass, p::T) where {T <: IntegerUnion} = CohomologyClass(t
# 5: Equality and hash
########################

Base.:(==)(cc1::CohomologyClass, cc2::CohomologyClass) = toric_variety(cc1) === toric_variety(cc2) && iszero(polynomial(cc1-cc2))
function Base.:(==)(cc1::CohomologyClass, cc2::CohomologyClass)
toric_variety(cc1) === toric_variety(cc2) && polynomial(cc1) == polynomial(cc2)
end

function Base.hash(cc::CohomologyClass, h::UInt)
b = 0x4de32042e67d89c8 % UInt
h = hash(toric_variety(cc), h)
return xor(h, b)
b = 0x4de32042e67d89c8 % UInt
h = hash(toric_variety(cc), h)
h = hash(polynomial(cc), h)
return xor(h, b)
end

######################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ Base.:*(c::T, tdc::ToricDivisorClass) where {T <: IntegerUnion} = toric_divisor_
########################

function Base.:(==)(tdc1::ToricDivisorClass, tdc2::ToricDivisorClass)
return toric_variety(tdc1) === toric_variety(tdc2) && iszero(divisor_class(tdc1) - divisor_class(tdc2))
return toric_variety(tdc1) === toric_variety(tdc2) && divisor_class(tdc1) == divisor_class(tdc2)
end

function Base.hash(tdc::ToricDivisorClass, h::UInt)
b = 0x118eb1fba136490c % UInt
h = hash(toric_variety(tdc), h)
h = hash(divisor_class(tdc), h)
return xor(h, b)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ Base.:^(l::ToricLineBundle, p::Int) = l^ZZRingElem(p)
########################

function Base.:(==)(l1::ToricLineBundle, l2::ToricLineBundle)
return toric_variety(l1) === toric_variety(l2) && iszero(divisor_class(l1) - divisor_class(l2))
return toric_variety(l1) === toric_variety(l2) && divisor_class(l1) == divisor_class(l2)
end

function Base.hash(l::ToricLineBundle, h::UInt)
b = 0xa2b0a2cd60a8ffbf % UInt
h = hash(toric_variety(l), h)
h = hash(divisor_class(l), h)
return xor(h, b)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ end


######################
# 6: Display
# 7: Display
######################

function Base.show(io::IO, tm::ToricMorphism)
Expand Down

0 comments on commit a7d55ef

Please sign in to comment.