@@ -119,10 +119,16 @@ from flint.flintlib.functions.gr cimport (
119119 gr_neg,
120120 gr_add,
121121 gr_add_si,
122+ gr_add_other,
123+ gr_other_add,
122124 gr_sub,
123125 gr_sub_si,
126+ gr_sub_other,
127+ gr_other_sub,
124128 gr_mul,
125129 gr_mul_si,
130+ gr_mul_other,
131+ gr_other_mul,
126132 gr_inv,
127133 gr_div,
128134 gr_div_si,
@@ -390,6 +396,123 @@ cdef class gr_ctx(flint_ctx):
390396 cdef inline truth_t _is_neg_one(self , gr x):
391397 return gr_is_neg_one(x.pval, self .ctx_t)
392398
399+ @cython.final
400+ cdef inline gr _neg(self , gr x):
401+ cdef int err
402+ cdef gr res = self .new_gr()
403+ err = gr_neg(res.pval, x.pval, self .ctx_t)
404+ if err != GR_SUCCESS:
405+ raise self ._error(err, " Cannot negate x in this context" )
406+ return res
407+
408+ @cython.final
409+ cdef inline gr _add(self , gr x, gr y):
410+ cdef int err
411+ cdef gr res = self .new_gr()
412+ err = gr_add(res.pval, x.pval, y.pval, self .ctx_t)
413+ if err != GR_SUCCESS:
414+ raise self ._error(err, " Cannot add x and y in this context" )
415+ return res
416+
417+ @cython.final
418+ cdef inline gr _add_other(self , gr x, gr y):
419+ cdef int err
420+ cdef gr res = self .new_gr()
421+ err = gr_add_other(res.pval, x.pval, y.pval, y.ctx.ctx_t, self .ctx_t)
422+ if err != GR_SUCCESS:
423+ raise self ._error(err, " Cannot add x and y in this context" )
424+ return res
425+
426+ @cython.final
427+ cdef inline gr _other_add(self , gr x, gr y):
428+ cdef int err
429+ cdef gr res = self .new_gr()
430+ err = gr_other_add(res.pval, x.pval, x.ctx.ctx_t, y.pval, self .ctx_t)
431+ if err != GR_SUCCESS:
432+ raise self ._error(err, " Cannot add x and y in this context" )
433+ return res
434+
435+ @cython.final
436+ cdef inline gr _add_si(self , gr x, slong y):
437+ cdef int err
438+ cdef gr res = self .new_gr()
439+ err = gr_add_si(res.pval, x.pval, y, self .ctx_t)
440+ if err != GR_SUCCESS:
441+ raise self ._error(err, " Cannot add x and y in this context" )
442+ return res
443+
444+ @cython.final
445+ cdef inline gr _sub(self , gr x, gr y):
446+ cdef int err
447+ cdef gr res = self .new_gr()
448+ err = gr_sub(res.pval, x.pval, y.pval, self .ctx_t)
449+ if err != GR_SUCCESS:
450+ raise self ._error(err, " Cannot sub x and y in this context" )
451+ return res
452+
453+ @cython.final
454+ cdef inline gr _sub_other(self , gr x, gr y):
455+ cdef int err
456+ cdef gr res = self .new_gr()
457+ err = gr_sub_other(res.pval, x.pval, y.pval, y.ctx.ctx_t, self .ctx_t)
458+ if err != GR_SUCCESS:
459+ raise self ._error(err, " Cannot sub x and y in this context" )
460+ return res
461+
462+ @cython.final
463+ cdef inline gr _other_sub(self , gr x, gr y):
464+ cdef int err
465+ cdef gr res = self .new_gr()
466+ err = gr_other_sub(res.pval, x.pval, x.ctx.ctx_t, y.pval, self .ctx_t)
467+ if err != GR_SUCCESS:
468+ raise self ._error(err, " Cannot sub x and y in this context" )
469+ return res
470+
471+ @cython.final
472+ cdef inline gr _sub_si(self , gr x, slong y):
473+ cdef int err
474+ cdef gr res = self .new_gr()
475+ err = gr_sub_si(res.pval, x.pval, y, self .ctx_t)
476+ if err != GR_SUCCESS:
477+ raise self ._error(err, " Cannot sub x and y in this context" )
478+ return res
479+
480+ @cython.final
481+ cdef inline gr _mul(self , gr x, gr y):
482+ cdef int err
483+ cdef gr res = self .new_gr()
484+ err = gr_mul(res.pval, x.pval, y.pval, self .ctx_t)
485+ if err != GR_SUCCESS:
486+ raise self ._error(err, " Cannot mul x and y in this context" )
487+ return res
488+
489+ @cython.final
490+ cdef inline gr _mul_other(self , gr x, gr y):
491+ cdef int err
492+ cdef gr res = self .new_gr()
493+ err = gr_mul_other(res.pval, x.pval, y.pval, y.ctx.ctx_t, self .ctx_t)
494+ if err != GR_SUCCESS:
495+ raise self ._error(err, " Cannot mul x and y in this context" )
496+ return res
497+
498+ @cython.final
499+ cdef inline gr _other_mul(self , gr x, gr y):
500+ cdef int err
501+ cdef gr res = self .new_gr()
502+ err = gr_other_mul(res.pval, x.pval, x.ctx.ctx_t, y.pval, self .ctx_t)
503+ if err != GR_SUCCESS:
504+ raise self ._error(err, " Cannot mul x and y in this context" )
505+ return res
506+
507+ @cython.final
508+ cdef inline gr _mul_si(self , gr x, slong y):
509+ cdef int err
510+ cdef gr res = self .new_gr()
511+ err = gr_mul_si(res.pval, x.pval, y, self .ctx_t)
512+ if err != GR_SUCCESS:
513+ raise self ._error(err, " Cannot mul x and y in this context" )
514+ return res
515+
393516 # @cython.final
394517 # cdef inline list _gens_recursive(self):
395518 # cdef int err
@@ -919,7 +1042,7 @@ cdef class gr_series_ctx(gr_ctx):
9191042@cython.no_gc
9201043cdef class gr(flint_scalar):
9211044 cdef gr_ptr pval
922- cdef gr_ctx ctx
1045+ cdef public gr_ctx ctx
9231046 cdef bint _init
9241047
9251048 @cython.final
0 commit comments