Skip to content

Commit

Permalink
broken refactor; need help
Browse files Browse the repository at this point in the history
  • Loading branch information
GiacomoPope committed Aug 9, 2024
1 parent 812fea4 commit ef2136a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
15 changes: 9 additions & 6 deletions src/flint/types/fq_default.pxd
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from flint.flintlib.fq_default cimport *
from flint.flintlib.fq cimport fq_ctx_struct
from flint.flintlib.fq_nmod cimport fq_nmod_ctx_struct
from flint.flintlib.fq_zech cimport fq_zech_ctx_struct
from flint.flintlib.fq_zech cimport fq_zech_is_primitive, fq_zech_multiplicative_order
from flint.flintlib.fq_nmod cimport fq_nmod_is_primitive, fq_nmod_multiplicative_order
from flint.flintlib.fq cimport fq_is_primitive, fq_multiplicative_order
from flint.types.fmpz cimport fmpz
from flint.flint_base.flint_base cimport flint_scalar

cdef extern from "flint/fq_default.h":
cdef fq_ctx_t FQ_DEFAULT_CTX_FQ(fq_default_ctx_t ctx)
cdef fq_zech_ctx_t FQ_DEFAULT_CTX_FQ_ZECH(fq_default_ctx_t ctx)
cdef fq_nmod_ctx_t FQ_DEFAULT_CTX_FQ_NMOD(fq_default_ctx_t ctx)
cdef fq_ctx_struct* FQ_DEFAULT_CTX_FQ(fq_default_ctx_t ctx)
cdef fq_zech_ctx_struct* FQ_DEFAULT_CTX_FQ_ZECH(fq_default_ctx_t ctx)
cdef fq_nmod_ctx_struct* FQ_DEFAULT_CTX_FQ_NMOD(fq_default_ctx_t ctx)

cpdef enum fq_default_type:
DEFAULT = 0
Expand All @@ -32,9 +35,9 @@ cdef class fq_default_ctx:
cdef _c_set_from_order(self, fmpz p, int d, char *var, fq_default_type fq_type=*)
cdef _c_set_from_modulus(self, modulus, char *var, fq_default_type fq_type=*)

# cdef fq_zech_ctx_t get_fq_zech_ctx_t(self)
# cdef fq_nmod_ctx_t get_fq_nmod_ctx_t(self)
# cdef fq_ctx_t get_fq_ctx_t(self)
cdef inline fq_ctx_struct* get_fq_ctx_t(self)
cdef inline fq_zech_ctx_struct* get_fq_zech_ctx_t(self)
cdef inline fq_nmod_ctx_struct* get_fq_nmod_ctx_t(self)

cdef class fq_default(flint_scalar):
cdef fq_default_ctx ctx
Expand Down
50 changes: 25 additions & 25 deletions src/flint/types/fq_default.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -424,29 +424,29 @@ cdef class fq_default_ctx:
return NotImplemented
return res

# cdef get_fq_zech_ctx_t(self):
# """
# Return the fq_zech_ctx_t type from the context
# """
# cdef fq_default s
# s = self
# return FQ_DEFAULT_CTX_FQ_ZECH(s.ctx.val)

# cdef get_fq_nmod_ctx_t(self):
# """
# Return the fq_nmod_ctx_t type from the context
# """
# cdef fq_default s
# s = self
# return FQ_DEFAULT_CTX_FQ_NMOD(s.ctx.val)
cdef inline fq_zech_ctx_struct* get_fq_zech_ctx_t(self):
"""
Return the fq_zech_ctx_t type from the context
"""
cdef fq_default s
s = self
return FQ_DEFAULT_CTX_FQ_ZECH(s.ctx.val)

cdef inline fq_nmod_ctx_struct* get_fq_nmod_ctx_t(self):
"""
Return the fq_nmod_ctx_t type from the context
"""
cdef fq_default s
s = self
return FQ_DEFAULT_CTX_FQ_NMOD(s.ctx.val)

# cdef fq_ctx_t get_fq_ctx_t(self):
# """
# Return the fq_ctx_t type from the context
# """
# cdef fq_default s
# s = self
# return FQ_DEFAULT_CTX_FQ(s.ctx.val)
cdef inline fq_ctx_struct* get_fq_ctx_t(self):
"""
Return the fq_ctx_t type from the context
"""
cdef fq_default s
s = self
return FQ_DEFAULT_CTX_FQ(s.ctx.val)

def __eq__(self, other):
"""
Expand Down Expand Up @@ -925,9 +925,9 @@ cdef class fq_default(flint_scalar):
cdef fq_default s
s = self
if self.ctx.fq_type == 1:
return 1 == fq_zech_is_primitive(s.val.fq_zech, FQ_DEFAULT_CTX_FQ_ZECH(s.ctx.val))
return 1 == fq_zech_is_primitive(s.val.fq_zech, s.get_fq_zech_ctx_t())
elif self.ctx.fq_type == 2:
return 1 == fq_nmod_is_primitive(s.val.fq_nmod, FQ_DEFAULT_CTX_FQ_NMOD(s.ctx.val))
return 1 == fq_nmod_is_primitive(s.val.fq_nmod, s.get_fq_nmod_ctx_t())
elif self.ctx.fq_type == 3:
return 1 == fq_is_primitive(s.val.fq, FQ_DEFAULT_CTX_FQ(s.ctx.val))
return 1 == fq_is_primitive(s.val.fq, self.get_fq_ctx_t())
raise TypeError("Can only call is_primitive() for elements with context FQ, FQ_ZECH and FQ_NMOD")

0 comments on commit ef2136a

Please sign in to comment.