From 8ded0df36fa98887c6960a6360df7413fbf0a85e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 7 Feb 2024 14:36:04 +0100 Subject: [PATCH] Add missing hash methods for maps (#3315) --- experimental/GModule/Cohomology.jl | 9 +++++++++ src/Rings/mpolyquo-localizations.jl | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/experimental/GModule/Cohomology.jl b/experimental/GModule/Cohomology.jl index bd5a95832c22..f4d8fe6cf8f3 100644 --- a/experimental/GModule/Cohomology.jl +++ b/experimental/GModule/Cohomology.jl @@ -1713,9 +1713,18 @@ function Oscar.matrix(M::FreeModuleHom{FreeMod{QQAbElem}, FreeMod{QQAbElem}}) end function ==(a::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism}, b::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism}) + domain(a) === domain(b) || return false + codomain(a) === codomain(b) || return false return matrix(a) == matrix(b) end +function Base.hash(a::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism}, h::UInt) + h = hash(domain(a), h) + h = hash(codomain(a), h) + h = hash(matrix(a), h) + return h +end + function Oscar.id_hom(A::AbstractAlgebra.FPModule) return Generic.ModuleHomomorphism(A, A, identity_matrix(base_ring(A), ngens(A))) end diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 341b01b8c2e9..9a1217bc6f40 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2407,6 +2407,14 @@ function Base.:(==)( return all(x->f(x) == g(x), gens(domain(f))) end +function Base.hash(f::Map{<:MPolyAnyRing, <:MPolyAnyRing}, h::UInt) + h = hash(domain(f), h) + h = hash(codomain(f), h) + # TODO: add in coefficient_map if available + h = hash(f.(gens(domain(f))), h) + return h +end + coefficient_map(f::MPolyLocalizedRingHom) = coefficient_map(restricted_map(f)) coefficient_map(f::MPolyQuoLocalizedRingHom) = coefficient_map(restricted_map(f))