Skip to content

Commit d857958

Browse files
committed
fix: add missing hash methods
1 parent cc62e1c commit d857958

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

src/GenOrd/FractionalIdeal.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ function ==(A::GenOrdFracIdl, B::GenOrdFracIdl)
276276
return isone(denominator(C, copy = false)) && isone(norm(C))
277277
end
278278

279+
function Base.hash(A::GenOrdFracIdl, h::UInt)
280+
return hash(order(A), hash(basis_matrix(A), h))
281+
end
282+
279283
################################################################################
280284
#
281285
# Colon

src/GrpAb/Map.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ end
216216

217217
==(f::FinGenAbGroupHom, g::FinGenAbGroupHom) = domain(f) === domain(g) && codomain(f) === codomain(g) && all(x -> f(x) == g(x), gens(domain(f)))
218218

219+
Base.hash(f::FinGenAbGroupHom, h::UInt) == zero(UInt)
220+
219221
################################################################################
220222
#
221223
# Inverse of a map

src/RCF/class_fields.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ function ==(a::ClassField, b::ClassField)
254254
return is_eq(kernel(h[2])[1], kernel(h[1])[1])
255255
end
256256

257+
function Base.hash(a::ClassField, h::UInt)
258+
return hash(a.base_ring, h)
259+
end
257260

258261
###############################################################################
259262
#

test/GenOrd/Ideal.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,14 @@
7777
end
7878
end
7979
end
80+
81+
let
82+
# hashing of fractional ideals
83+
k = GF(7)
84+
kx, x = rational_function_field(k, "x")
85+
kt = parent(numerator(x))
86+
ky, y = polynomial_ring(kx, "y")
87+
F, a = function_field(y^2+x)
88+
O = integral_closure(kt, F)
89+
@test hash(fractional_ideal(a*O)) == hash(fractional_ideal(a*O))
90+
end

test/GrpAb/Map.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,12 @@
124124
@test_throws ArgumentError preinverse(f)
125125
@test_throws ArgumentError postinverse(g)
126126
end
127+
128+
let
129+
G = abelian_group([2, 2])
130+
h = zero_map(G, G);
131+
hh = zero_map(G, G);
132+
h == hh
133+
@test hash(h) == hash(hh)
134+
end
127135
end

test/RCF/rcf.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,16 @@ let
380380
L, = number_field(x^3 - 840539241479//13824*a^5 - 18036715089631//9216*a^4 - 18036715089631//9216*a^3 - 840539241479//13824*a^2 - 7320065966297//9216)
381381
@test !is_abelian(L)
382382
end
383+
384+
let
385+
# fix hashing
386+
K, = quadratic_field(-1)
387+
OK = maximal_order(K)
388+
C = ray_class_field(1*OK)
389+
CC = ray_class_field(1*OK)
390+
@test C == CC
391+
@test hash(C) == hash(CC)
392+
D = Dict()
393+
D[C] = 1
394+
@test haskey(D, CC)
395+
end

0 commit comments

Comments
 (0)