From d3d0ab8cf2d80b81db2e6bfc69b3de1e9f2478ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:13:36 +0100 Subject: [PATCH 01/13] Add `hash(::Divisor)` --- src/FunField/Divisor.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FunField/Divisor.jl b/src/FunField/Divisor.jl index ace9bbb256..e5ece7b64b 100644 --- a/src/FunField/Divisor.jl +++ b/src/FunField/Divisor.jl @@ -225,6 +225,8 @@ end Base.:(==)(D1::Divisor, D2::Divisor) = ideals(D1) == ideals(D2) Base.isequal(D1::Divisor, D2::Divisor) = a == b +Base.hash(D::Divisor, h::UInt) = hash(ideals(D), h) + ################################################################################ # # Divisor arithmetic From fe26d1c1e4e4bcfa4ce257e52b6e1367396a0a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:15:11 +0100 Subject: [PATCH 02/13] Add `hash(::EllipticCurve)` --- src/EllCrv/EllCrv.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/EllCrv/EllCrv.jl b/src/EllCrv/EllCrv.jl index 264ba5cf96..52be1c875c 100644 --- a/src/EllCrv/EllCrv.jl +++ b/src/EllCrv/EllCrv.jl @@ -372,6 +372,12 @@ function ==(E::EllipticCurve, F::EllipticCurve) return a_invariants(E) == a_invariants(F) && base_field(E) == base_field(F) end +function Base.hash(E::EllipticCurve, h::UInt) + h = hash(a_invariants(E), h) + h = hash(base_field(E), h) + return h +end + ################################################################################ # # Elementary invariants From cd9d68d9eadeeb21742b90e9a770810890de5d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:17:39 +0100 Subject: [PATCH 03/13] Add `hash(::FunFldDiff)` --- src/FunField/Differential.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/FunField/Differential.jl b/src/FunField/Differential.jl index 2e1a64ccad..b44add5dbe 100644 --- a/src/FunField/Differential.jl +++ b/src/FunField/Differential.jl @@ -79,6 +79,12 @@ function Base.:(==)(df::FunFldDiff, dg::FunFldDiff) return function_field(df) === function_field(df) && df.f == df.f end +function Base.hash(df::FunFldDiff, h::UInt) + h = hash(function_field(df), h) + h = hash(df.f, h) + return h +end + ################################################################################ # # Arithmetic From 576ae83b2110636a10d5a6e7e6fd83a521bbcc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:20:51 +0100 Subject: [PATCH 04/13] Fix `==(::KodairaSymbol,::KodairaSymbol)`; add hash --- src/EllCrv/LocalData.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/EllCrv/LocalData.jl b/src/EllCrv/LocalData.jl index 7f7efd63cd..75ece2ae29 100644 --- a/src/EllCrv/LocalData.jl +++ b/src/EllCrv/LocalData.jl @@ -817,7 +817,11 @@ end Return true if $K1$ and $K2$ are the same Kodaira symbol. """ function ==(K1::KodairaSymbol, K2::KodairaSymbol) - return K1.ksymbol == K2.kymbol + return K1.ksymbol == K2.ksymbol +end + +function Base.hash(K::KodairaSymbol, h::UInt) + return hash(K.ksymbol, h) end From 260a79cc1b4af21cc1dabea5ec1c29cd2d160cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:22:22 +0100 Subject: [PATCH 05/13] Add `hash` for `Line` and `Polygon` --- src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl b/src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl index 222cfefdd6..24e9ecc573 100644 --- a/src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl +++ b/src/NumFieldOrd/NfOrd/MaxOrd/Polygons.jl @@ -91,10 +91,18 @@ function Base.:(==)(L::Line, L2::Line) return L.points == L2.points end +function Base.hash(L::Line, h::UInt) + return hash(L.points, h) +end + function Base.:(==)(P::Polygon, P2::Polygon) return P.lines == P2.lines end +function Base.hash(P::Polygon, h::UInt) + return hash(P.lines, h) +end + ############################################################################### # # Lower convex hull of a set of points From 73a7df17627eed08df966ddf80d03b1e4d8763b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:24:01 +0100 Subject: [PATCH 06/13] Add `hash(::RelSimpleNumFieldEmbedding)` --- src/NumField/ComplexEmbeddings/NfRel.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NumField/ComplexEmbeddings/NfRel.jl b/src/NumField/ComplexEmbeddings/NfRel.jl index 254d57095b..e2e2c42032 100644 --- a/src/NumField/ComplexEmbeddings/NfRel.jl +++ b/src/NumField/ComplexEmbeddings/NfRel.jl @@ -63,6 +63,12 @@ function Base.:(==)(f::RelSimpleNumFieldEmbedding, g::RelSimpleNumFieldEmbedding _absolute_index(f) == _absolute_index(g) end +function Base.hash(f::RelSimpleNumFieldEmbedding, h::UInt) + h = hash(number_field(f), h) + h = hash(_absolute_index(f), h) + return h +end + ################################################################################ # # Conjugate embedding From f632f025b352b020b887d06f8fffe5eceb2d2bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:24:54 +0100 Subject: [PATCH 07/13] Add `hash(::QuadBin)` --- src/QuadForm/QuadBin.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/QuadForm/QuadBin.jl b/src/QuadForm/QuadBin.jl index 991c3fe7b8..a75a54b032 100644 --- a/src/QuadForm/QuadBin.jl +++ b/src/QuadForm/QuadBin.jl @@ -295,6 +295,14 @@ function ==(f1::QuadBin, f2::QuadBin) return f1[1] == f2[1] && f1[2] == f2[2] && f1[3] == f2[3] end +function Base.hash(f::QuadBin, h::UInt) + h = hash(base_ring(f), h) + h = hash(f[1], h) + h = hash(f[2], h) + h = hash(f[3], h) + return h +end + ############################################################################### # # Arithmetic From 532ed81bdb871cf2342944c7f3e5170ebac20b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:26:14 +0100 Subject: [PATCH 08/13] Add `hash(::AbsSimpleNumFieldEmbedding)` --- src/NumField/ComplexEmbeddings/NfAbs.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NumField/ComplexEmbeddings/NfAbs.jl b/src/NumField/ComplexEmbeddings/NfAbs.jl index 3258ffa1bb..391ad7651e 100644 --- a/src/NumField/ComplexEmbeddings/NfAbs.jl +++ b/src/NumField/ComplexEmbeddings/NfAbs.jl @@ -68,6 +68,12 @@ function Base.:(==)(f::AbsSimpleNumFieldEmbedding, g::AbsSimpleNumFieldEmbedding _absolute_index(f) == _absolute_index(g) end +function Base.hash(f::AbsSimpleNumFieldEmbedding, h::UInt) + h = hash(number_field(f), h) + h = hash(_absolute_index(f), h) + return h +end + ################################################################################ # # String I/O From 9426bd2ee6620ac1f2451d93f2036b4a9cb816da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:27:31 +0100 Subject: [PATCH 09/13] Add `hash(::AbsNumFieldOrderSet)` --- src/NumFieldOrd/NfOrd/NfOrd.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NumFieldOrd/NfOrd/NfOrd.jl b/src/NumFieldOrd/NfOrd/NfOrd.jl index 7659530ca4..91cc399ae6 100644 --- a/src/NumFieldOrd/NfOrd/NfOrd.jl +++ b/src/NumFieldOrd/NfOrd/NfOrd.jl @@ -1152,6 +1152,10 @@ function ==(R::AbsNumFieldOrderSet, S::AbsNumFieldOrderSet) return R.nf === S.nf end +function Base.hash(R::AbsNumFieldOrderSet, h::UInt) + return hash(R.nf, h) +end + ################################################################################ # # Trace matrix From dbb016f32e25be1172aae2d5bbd54f76b5b337d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:28:43 +0100 Subject: [PATCH 10/13] Add `hash(::AbsNumFieldOrder)` --- src/NumFieldOrd/NfOrd/NfOrd.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NumFieldOrd/NfOrd/NfOrd.jl b/src/NumFieldOrd/NfOrd/NfOrd.jl index 91cc399ae6..7924f509e5 100644 --- a/src/NumFieldOrd/NfOrd/NfOrd.jl +++ b/src/NumFieldOrd/NfOrd/NfOrd.jl @@ -1139,6 +1139,14 @@ function ==(R::AbsNumFieldOrder, S::AbsNumFieldOrder) return hnf(R.basis_matrix) == hnf(S.basis_matrix) end +function hash(R::AbsNumFieldOrder, h::UInt) + h = hash(nf(R), h) + h = hash(discriminant(R), h) + assure_has_basis_matrix(R) + h = hash(hnf(R.basis_matrix), h) + return h +end + @doc raw""" is_contained(R::AbsNumFieldOrder, S::AbsNumFieldOrder) -> Bool From 65b40d31f7fae15f525d07c0efeb0b4c950cfcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:30:39 +0100 Subject: [PATCH 11/13] Add `hash(::QmodnZ)` --- src/GrpAb/Dual.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GrpAb/Dual.jl b/src/GrpAb/Dual.jl index 7196e6f356..60e70e8090 100644 --- a/src/GrpAb/Dual.jl +++ b/src/GrpAb/Dual.jl @@ -144,6 +144,12 @@ function Base.:(==)(a::QmodnZ, b::QmodnZ) return a.n == b.n && a.d == b.d end +function Base.hash(a::QmodnZ, h::UInt) + h = hash(a.n, h) + h = hash(a.d, h) + return h +end + function Base.:(==)(a::QmodnZElem, b::QmodnZElem) if parent(a).trivialmodulus return is_integral(a.elt - b.elt) @@ -158,7 +164,7 @@ function Base.hash(a::QmodnZElem, h::UInt) if parent(a).trivialmodulus return hash(a.elt, h) end - error("not implemented") + return h end for T in [ZZRingElem, Integer, QQFieldElem, Rational] From f6cf0f204eab2e8998fb42a74648a21c7d7f135f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:31:35 +0100 Subject: [PATCH 12/13] Add `hash(::Union{ZZIdl, ZZFracIdl})` --- src/NumField/QQ.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/NumField/QQ.jl b/src/NumField/QQ.jl index a6d80a2f02..7b72284e09 100644 --- a/src/NumField/QQ.jl +++ b/src/NumField/QQ.jl @@ -32,8 +32,6 @@ struct ZZFracIdl <: NumFieldOrderFractionalIdeal end end -Base.hash(x::ZZIdl, h::UInt) = hash(gen(x), h) - order(::ZZIdl) = ZZ order(::ZZFracIdl) = ZZ @@ -93,10 +91,18 @@ function ==(I::ZZIdl, J::ZZIdl) return I.gen == J.gen end +function Base.hash(I::ZZIdl, h::UInt) + return hash(I.gen, h) +end + function ==(I::ZZFracIdl, J::ZZFracIdl) return I.gen == J.gen end +function Base.hash(I::ZZFracIdl, h::UInt) + return hash(I.gen, h) +end + # access gen(I::ZZIdl) = I.gen From 1250a61c4eab6a039940822e005b25e0061562c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 29 Nov 2024 16:34:26 +0100 Subject: [PATCH 13/13] Add `hash(::EllCrvIso)` --- src/EllCrv/Isomorphisms.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/EllCrv/Isomorphisms.jl b/src/EllCrv/Isomorphisms.jl index 4cfc3be0f1..f663fb800b 100644 --- a/src/EllCrv/Isomorphisms.jl +++ b/src/EllCrv/Isomorphisms.jl @@ -608,6 +608,14 @@ function ==(f::EllCrvIso, g::EllCrvIso) return f.data == g.data && Ef == Eg && base_field(Ef) == base_field(Eg) end +function Base.hash(f::EllCrvIso, h::UInt) + Ef = domain(f) + h = hash(f.data, h) + h = hash(Ef, h) + h = hash(base_field(Ef), h) + return h +end + ################################################################################ #