Skip to content

Commit b2d6e89

Browse files
committed
feat: add gr context for fexpr
1 parent c92cb82 commit b2d6e89

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

src/flint/types/gr.pxd

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ from flint.flintlib.functions.gr_domains cimport (
5959
gr_ctx_init_complex_float_acf,
6060
gr_ctx_init_real_arb,
6161
gr_ctx_init_complex_acb,
62+
gr_ctx_init_fexpr,
6263

6364
_gr_ctx_qqbar_set_limits,
6465
)
@@ -402,6 +403,25 @@ cdef class _gr_fmpzi_ctx(gr_scalar_ctx):
402403
return ctx
403404

404405

406+
@cython.no_gc
407+
cdef class _gr_fexpr_ctx(gr_scalar_ctx):
408+
409+
@staticmethod
410+
cdef inline _gr_fexpr_ctx _new():
411+
cdef _gr_fexpr_ctx ctx
412+
ctx = _gr_fexpr_ctx.__new__(_gr_fexpr_ctx)
413+
gr_ctx_init_fexpr(ctx.ctx_t)
414+
ctx._init = True
415+
return ctx
416+
417+
418+
# The global contexts for use in cython code:
419+
cdef _gr_fmpz_ctx gr_fmpz_ctx_c
420+
cdef _gr_fmpq_ctx gr_fmpq_ctx_c
421+
cdef _gr_fmpzi_ctx gr_fmpzi_ctx_c
422+
cdef _gr_fexpr_ctx gr_fexpr_ctx_c
423+
424+
405425
@cython.no_gc
406426
cdef class gr_nmod_ctx(gr_scalar_ctx):
407427
cdef ulong n
@@ -683,13 +703,6 @@ cdef class gr_complex_acb_ctx(gr_scalar_ctx):
683703
return ctx
684704

685705

686-
# @cython.no_gc
687-
# cdef class gr_fexpr_ctx(gr_scalar_ctx):
688-
#
689-
# @staticmethod
690-
# cdef gr_fexpr_ctx _new()
691-
692-
693706
# @cython.no_gc
694707
# cdef class _gr_fmpz_poly_ctx(gr_poly_ctx):
695708
#
@@ -711,12 +724,6 @@ cdef class gr_complex_acb_ctx(gr_scalar_ctx):
711724
# cdef _gr_gr_poly_ctx _new()
712725

713726

714-
# The global contexts for use in cython code:
715-
cdef _gr_fmpz_ctx gr_fmpz_ctx_c
716-
cdef _gr_fmpq_ctx gr_fmpq_ctx_c
717-
cdef _gr_fmpzi_ctx gr_fmpzi_ctx_c
718-
719-
720727
@cython.no_gc
721728
cdef class gr(flint_scalar):
722729
cdef gr_ptr pval

src/flint/types/gr.pyx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,17 @@ cdef class gr_matrix_ring_ctx(gr_ctx):
181181
pass
182182

183183

184-
cdef _gr_fmpz_ctx gr_fmpz_ctx_c
185-
cdef _gr_fmpq_ctx gr_fmpq_ctx_c
186-
cdef _gr_fmpzi_ctx gr_fmpzi_ctx_c
184+
# Global contexts for Cython code
185+
cdef _gr_fmpz_ctx gr_fmpz_ctx_c = _gr_fmpz_ctx._new()
186+
cdef _gr_fmpq_ctx gr_fmpq_ctx_c = _gr_fmpq_ctx._new()
187+
cdef _gr_fmpzi_ctx gr_fmpzi_ctx_c = _gr_fmpzi_ctx._new()
188+
cdef _gr_fexpr_ctx gr_fexpr_ctx_c = _gr_fexpr_ctx._new()
189+
190+
# Global contexts for Python code
191+
gr_fmpz_ctx = gr_fmpz_ctx_c
192+
gr_fmpq_ctx = gr_fmpq_ctx_c
193+
gr_fmpzi_ctx = gr_fmpzi_ctx_c
194+
gr_fexpr_ctx = gr_fexpr_ctx_c
187195

188196

189197
@cython.no_gc
@@ -219,15 +227,15 @@ cdef class _gr_fmpzi_ctx(gr_scalar_ctx):
219227
return "gr_fmpzi_ctx"
220228

221229

222-
# Global contexts for Cython code
223-
gr_fmpz_ctx_c = _gr_fmpz_ctx._new()
224-
gr_fmpq_ctx_c = _gr_fmpq_ctx._new()
225-
gr_fmpzi_ctx_c = _gr_fmpzi_ctx._new()
230+
@cython.no_gc
231+
cdef class _gr_fexpr_ctx(gr_scalar_ctx):
226232

227-
# Global contexts for Python code
228-
gr_fmpz_ctx = gr_fmpz_ctx_c
229-
gr_fmpq_ctx = gr_fmpq_ctx_c
230-
gr_fmpzi_ctx = gr_fmpzi_ctx_c
233+
@staticmethod
234+
def new() -> _gr_fexpr_ctx:
235+
return gr_fexpr_ctx_c
236+
237+
def __repr__(self):
238+
return "gr_fexpr_ctx"
231239

232240

233241
@cython.no_gc

0 commit comments

Comments
 (0)