Skip to content

Commit

Permalink
Add missing hash methods for maps (#3315)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Feb 7, 2024
1 parent 968e9e4 commit 8ded0df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 8ded0df

Please sign in to comment.