Skip to content

Commit

Permalink
Add missing hash methods for maps
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Feb 5, 2024
1 parent e4bb400 commit 8152506
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1713,9 +1713,15 @@ 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)
return hash(matrix(a), 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 8152506

Please sign in to comment.