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 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 + ################################################################################ # 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 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 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 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] 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 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 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 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 diff --git a/src/NumFieldOrd/NfOrd/NfOrd.jl b/src/NumFieldOrd/NfOrd/NfOrd.jl index 7659530ca4..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 @@ -1152,6 +1160,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 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