Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Produce different (and non-zero...) hashes for FLINT implems of FFs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Pierre Flori committed Aug 19, 2014
1 parent bc81680 commit 0661730
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/sage/rings/finite_rings/finite_field_flint_fq.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ cdef class FiniteField_flint_fq(FiniteField):
self._degree = n
self._kwargs = {}

self.__hash = hash((p**n, name, modulus, 'flint_fq'))

# Cannot be done in cinit as we need modulus
cdef Integer ci
cdef fmpz_t cflint, pflint
Expand Down Expand Up @@ -194,11 +196,7 @@ cdef class FiniteField_flint_fq(FiniteField):
sage: {GF(9, 'b', impl='flint_fq'): 1} # indirect doctest
{Finite Field in b of size 3^2: 1}
"""
try:
return self.__hash
except AttributeError:
self.__hash = hash((self.cardinality(), self.variable_name(), self._modulus))
return self.__hash
return self.__hash

def __reduce__(self):
"""
Expand Down
10 changes: 4 additions & 6 deletions src/sage/rings/finite_rings/finite_field_flint_fq_nmod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ cdef class FiniteField_flint_fq_nmod(FiniteField):
or (proof and not pint.is_prime())
or (not proof and not pint.is_pseudoprime())):
raise ArithmeticError("p must be a prime number")
if (p > sys.maxint):
if (pint > sys.maxint):
raise ValueError("p must fit in a machine word")
Fp = GF(pint)

Expand All @@ -146,6 +146,8 @@ cdef class FiniteField_flint_fq_nmod(FiniteField):
self._degree = n
self._kwargs = {}

self.__hash = hash((pint**n, name, modulus, 'flint_fq_nmod'))

# Cannot be done in cinit as we need modulus
cdef Integer ci
cdef long clong, plong
Expand Down Expand Up @@ -193,11 +195,7 @@ cdef class FiniteField_flint_fq_nmod(FiniteField):
sage: {GF(9, 'b', impl='flint_fq_nmod'): 1} # indirect doctest
{Finite Field in b of size 3^2: 1}
"""
try:
return self.__hash
except AttributeError:
self.__hash = hash((self.cardinality(), self.variable_name(), self._modulus))
return self.__hash
return self.__hash

def __reduce__(self):
"""
Expand Down

0 comments on commit 0661730

Please sign in to comment.