diff --git a/src/flint/types/fq_default.pxd b/src/flint/types/fq_default.pxd index da226244..50f35013 100644 --- a/src/flint/types/fq_default.pxd +++ b/src/flint/types/fq_default.pxd @@ -1,4 +1,7 @@ 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 @@ -6,9 +9,9 @@ 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 @@ -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 diff --git a/src/flint/types/fq_default.pyx b/src/flint/types/fq_default.pyx index 39d6ad26..c3cdaf40 100644 --- a/src/flint/types/fq_default.pyx +++ b/src/flint/types/fq_default.pyx @@ -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): """ @@ -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")