Skip to content

Commit

Permalink
Add hash methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 11, 2023
1 parent 3b57c98 commit fa49b72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Groups/homomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ function Base.show(io::IO, x::GAPGroupHomomorphism)
end

function ==(f::GAPGroupHomomorphism{S,T}, g::GAPGroupHomomorphism{S,T}) where S where T
return f.map == g.map
return f.map == g.map
end

function Base.hash(f::GAPGroupHomomorphism{S,T}, h::UInt) where S where T
b = 0xdc777737af4c0c7b % UInt
return xor(hash(f.map, hash((S, T), h)), b)
end

Base.:*(f::GAPGroupHomomorphism{S, T}, g::GAPGroupHomomorphism{T, U}) where S where T where U = compose(f, g)
Expand Down
5 changes: 5 additions & 0 deletions src/Modules/ModulesGraded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,11 @@ function Base.:(==)(F::FreeMod_dec, G::FreeMod_dec)
return forget_decoration(F) == forget_decoration(G) && F.d == G.d
end

function Base.hash(F::FreeMod_dec, h::UInt)
b = 0x13d6e1b453cb661a % UInt
return xor(hash(forget_decoration(F), hash(F.d, h)), b)
end

###############################################################################
# FreeModElem_dec constructors
###############################################################################
Expand Down
4 changes: 4 additions & 0 deletions src/Rings/PBWAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,10 @@ function Base.:(==)(a::PBWAlgIdeal{D, T, S}, b::PBWAlgIdeal{D, T, S}) where {D,
return is_subset(a, b) && is_subset(b, a)
end

function Base.hash(a::PBWAlgIdeal{D, T, S}, h::UInt) where {D, T, S}
b = 0x91c65dda1eed350f % UInt
return xor(hash(base_ring(a), hash(D, h)), b)
end

#### elimination

Expand Down

0 comments on commit fa49b72

Please sign in to comment.