Skip to content

Commit 57e6885

Browse files
committed
feat: fixes for adding gr_ scalar types
1 parent ef30ebf commit 57e6885

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

src/flint/types/gr.pxd

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,72 @@ cdef class gr_ctx(flint_ctx):
162162
return AssertionError("Bad error code")
163163

164164

165+
cdef class gr_scalar_ctx(gr_ctx):
166+
pass
167+
168+
169+
cdef class gr_poly_ctx(gr_ctx):
170+
pass
171+
172+
173+
cdef class gr_mpoly_ctx(gr_ctx):
174+
pass
175+
176+
177+
cdef class gr_matrix_domain_ctx(gr_ctx):
178+
pass
179+
180+
181+
cdef class gr_matrix_space_ctx(gr_ctx):
182+
pass
183+
184+
185+
cdef class gr_matrix_ring_ctx(gr_ctx):
186+
pass
187+
188+
165189
@cython.no_gc
166-
cdef class _gr_fmpz_ctx(gr_ctx):
190+
cdef class _gr_fmpz_ctx(gr_scalar_ctx):
167191

168192
@staticmethod
169193
cdef _gr_fmpz_ctx _new()
170194

171195

172196
@cython.no_gc
173-
cdef class _gr_fmpq_ctx(gr_ctx):
197+
cdef class _gr_fmpq_ctx(gr_scalar_ctx):
174198

175199
@staticmethod
176200
cdef _gr_fmpq_ctx _new()
177201

178202

179203
@cython.no_gc
180-
cdef class _gr_fmpzi_ctx(gr_ctx):
204+
cdef class _gr_fmpzi_ctx(gr_scalar_ctx):
181205

182206
@staticmethod
183207
cdef _gr_fmpzi_ctx _new()
184208

185209

210+
@cython.no_gc
211+
cdef class _gr_fmpz_poly_ctx(gr_poly_ctx):
212+
213+
@staticmethod
214+
cdef _gr_fmpz_poly_ctx _new()
215+
216+
217+
@cython.no_gc
218+
cdef class _gr_fmpq_poly_ctx(gr_poly_ctx):
219+
220+
@staticmethod
221+
cdef _gr_fmpq_poly_ctx _new()
222+
223+
224+
@cython.no_gc
225+
cdef class _gr_gr_poly_ctx(gr_poly_ctx):
226+
227+
@staticmethod
228+
cdef _gr_gr_poly_ctx _new()
229+
230+
186231
# The global contexts for use in cython code:
187232
cdef _gr_fmpz_ctx gr_fmpz_ctx_c
188233
cdef _gr_fmpq_ctx gr_fmpq_ctx_c
@@ -362,7 +407,6 @@ cdef class gr(flint_scalar):
362407
raise self._error(err, "Failed to compute lcm of gr objects")
363408
return res
364409

365-
# XXX: Needs gr_vec_t
366410
cdef inline _factor(self):
367411
cdef int err, i
368412
cdef slong length, exp_s

src/flint/types/gr.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,14 @@ cdef class gr(flint_scalar):
327327
err = gr_set_si(other_gr.pval, other, self.ctx.ctx_t)
328328
if err != GR_SUCCESS:
329329
raise self.ctx._error(err, "Cannot set gr from int")
330-
elif not isinstance(other, gr):
330+
elif isinstance(other, gr):
331+
other_gr = other
332+
else:
331333
raise NotImplementedError("Cannot compare gr with non-gr objects")
332334

333335
if self.ctx != other_gr.ctx:
334336
raise NotImplementedError("Cannot compare gr with different contexts")
335337

336-
other_gr = other
337-
338338
if op == 0:
339339
raise NotImplementedError("Cannot compare gr with <")
340340
# res = self._lt(other_gr)
@@ -460,7 +460,7 @@ cdef class gr(flint_scalar):
460460
if not isinstance(other, gr):
461461
raise TypeError("gcd when other is not gr.")
462462
other_gr = other
463-
if not self.ctx == other.ctx:
463+
if not self.ctx == other_gr.ctx:
464464
raise TypeError("gcd of gr with different contexts.")
465465
return self._gcd(other_gr)
466466

@@ -469,7 +469,7 @@ cdef class gr(flint_scalar):
469469
if not isinstance(other, gr):
470470
raise TypeError("gcd when other is not gr.")
471471
other_gr = other
472-
if not self.ctx == other.ctx:
472+
if not self.ctx == other_gr.ctx:
473473
raise TypeError("gcd of gr with different contexts.")
474474
return self._gcd(other_gr)
475475

0 commit comments

Comments
 (0)