Skip to content

Bad hash for LaurentMPolyWrap #2375

@karlwessel

Description

@karlwessel

The hash value for a LaurentMPolyWrap a and its negative is equal:

julia> using AbstractAlgebra

julia> R, (a, b) = laurent_polynomial_ring(QQ, [:a, :b])
(Multivariate Laurent polynomial ring in 2 variables over rationals, AbstractAlgebra.Generic.LaurentMPolyWrap{Rational{BigInt}, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}, AbstractAlgebra.Generic.LaurentMPolyWrapRing{Rational{BigInt}, AbstractAlgebra.Generic.MPolyRing{Rational{BigInt}}}}[a, b])

julia> hash(a) == hash(-a)
true

It could be caused by this line:

h ^= 0x9c64b62806a3d51d%UInt

which does not make much sense to me, it seems to be always zero for every even integer:

julia> for i in 1:10
       println(UInt(i)^0x9c64b62806a3d51d)
       end
1
0
6835022377903901075
0
17694793150345534037
0
5333000080861380455
0
15995747220507601513
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions