Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we need more hashing #515

Merged
merged 3 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Polymake"
uuid = "d720cf60-89b5-51f5-aff5-213f193123e7"
repo = "https://github.com/oscar-system/Polymake.jl.git"
version = "0.11.27"
version = "0.11.28"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
1 change: 1 addition & 0 deletions src/oscarnumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ end
(::Type{<:Rational})(on::OscarNumber) = convert(Rational, unwrap(on))
Integer(on::OscarNumber) = convert(Integer, unwrap(on))
Rational(on::OscarNumber) = convert(Rational, unwrap(on))
Base.hash(on::OscarNumber, h::UInt) = hash(unwrap(on), h)

# we don't support conversion for concrete types inside the OscarNumber here
(::Type{<:QuadraticExtension{<:Rational}})(on::OscarNumber) = QuadraticExtension{Rational}(Rational(on))
Expand Down
2 changes: 2 additions & 0 deletions src/quadraticextension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Base.one(::QuadraticExtension{T}) where T<:qe_suppT = QuadraticExtension{T}(1)

generating_field_elements(qe::QuadraticExtension{T}) where T<:qe_suppT = (a = _a(qe), b = _b(qe), r =_r(qe))

Base.hash(qe::QuadraticExtension{T}, h::UInt) where T<:qe_suppT = Base.hash((_a(qe),_b(qe),_r(qe)), h)

# we might need to split this up
# if we should wrap `QuadraticExtension` with another scalar than `Rational`
function Base.promote_rule(::Type{<:QuadraticExtension{T}},
Expand Down
13 changes: 13 additions & 0 deletions test/vectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ using Polymake.CxxWrap
end
M = Polymake.OscarNumber(m)
A2 = Polymake.OscarNumber(a2)

@testset "hashing" begin
vi = Polymake.Integer[1, 1, -7, 0, 0, -7]
vr = Polymake.Rational[vi..., 7//3, Polymake.Rational(7,3)]
vq = Vector{Polymake.QuadraticExtension{Polymake.Rational}}(vr)
push!(vq, Polymake.QuadraticExtension{Polymake.Rational}(1,2,3))
von = Polymake.OscarNumber[M, A2, A2*2-A2, M+0]

@test length(unique(vi)) == 3
@test length(unique(vr)) == 4
@test length(unique(vq)) == 5
@test length(unique(von)) == 2
end

jl_v = [1,2,3]
@testset verbose=true "Constructors/Converts" begin
Expand Down
Loading