From 7b1796cf2d34c7e7a258168aa71db9ac9a63bf85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 17 May 2023 14:32:03 +0200 Subject: [PATCH] Update `==` and `hash` for toric types --- .../ToricVarieties/AlgebraicCycles/constructors.jl | 9 +++++---- .../ToricVarieties/CohomologyClasses/constructors.jl | 11 +++++++---- .../ToricDivisorClasses/constructors.jl | 3 ++- .../ToricVarieties/ToricLineBundles/constructors.jl | 3 ++- .../ToricVarieties/ToricMorphisms/constructors.jl | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl index f82f08495bd5..6d988b235acb 100644 --- a/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/AlgebraicCycles/constructors.jl @@ -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 diff --git a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl index e18227767eac..9dac8d513f03 100644 --- a/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/CohomologyClasses/constructors.jl @@ -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 ###################### diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl index 1b842c0bf568..f65f573b3392 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricDivisorClasses/constructors.jl @@ -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 diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl index a0a3119c5475..a0b095b05826 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricLineBundles/constructors.jl @@ -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 diff --git a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl index cd5eed9ce9b7..96b22f64cbd6 100644 --- a/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl +++ b/src/AlgebraicGeometry/ToricVarieties/ToricMorphisms/constructors.jl @@ -237,7 +237,7 @@ end ###################### -# 6: Display +# 7: Display ###################### function Base.show(io::IO, tm::ToricMorphism)