File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ cimport cython
2+
13from flint.flint_base.flint_base cimport flint_scalar
24from flint.flintlib.flint cimport mp_limb_t, ulong
35from flint.flintlib.nmod cimport nmod_t
46
57
8+ @cython.no_gc
69cdef class nmod_ctx:
710 cdef nmod_t mod
811 cdef bint _is_prime
912
1013 @staticmethod
11- cdef nmod_ctx any_as_nmod_ctx(obj)
14+ cdef any_as_nmod_ctx(obj)
1215 @staticmethod
1316 cdef _get_ctx(int mod)
1417 @staticmethod
1518 cdef _new_ctx(ulong mod)
1619
20+ @cython.final
1721 cdef int any_as_nmod(self , mp_limb_t * val, obj) except - 1
22+ @cython.final
1823 cdef nmod new_nmod(self )
1924
2025
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ cdef class nmod_ctx:
4848 return nmod_ctx._get_ctx(mod)
4949
5050 @staticmethod
51- cdef nmod_ctx any_as_nmod_ctx(obj):
51+ cdef any_as_nmod_ctx(obj):
5252 """ Convert an ``nmod_ctx`` or ``int`` to an ``nmod_ctx``."""
5353 if typecheck(obj, nmod_ctx):
5454 return obj
@@ -163,7 +163,6 @@ cdef class nmod_ctx:
163163 return r
164164
165165
166- @cython.no_gc
167166cdef class nmod(flint_scalar):
168167 """
169168 The nmod type represents elements of Z/nZ for word-size n.
@@ -173,9 +172,11 @@ cdef class nmod(flint_scalar):
173172
174173 """
175174 def __init__ (self , val , mod ):
176- ctx = nmod_ctx.any_as_nmod_ctx(mod)
177- if ctx is NotImplemented :
175+ cdef nmod_ctx ctx
176+ c = nmod_ctx.any_as_nmod_ctx(mod)
177+ if c is NotImplemented :
178178 raise TypeError (" Invalid context/modulus for nmod: %s " % mod)
179+ ctx = c
179180 if not ctx.any_as_nmod(& self .val, val):
180181 raise TypeError (" cannot create nmod from object of type %s " % type (val))
181182 self .ctx = ctx
Original file line number Diff line number Diff line change 1+ cimport cython
2+
13from flint.flint_base.flint_base cimport flint_mat
24
5+ from flint.flintlib.nmod cimport nmod_t
36from flint.flintlib.nmod_mat cimport nmod_mat_t
4- from flint.flintlib.flint cimport mp_limb_t
7+ from flint.flintlib.flint cimport mp_limb_t, ulong
8+
9+ from flint.types.nmod cimport nmod_ctx, nmod
10+ from flint.types.nmod_poly cimport nmod_poly_ctx, nmod_poly
11+
12+
13+ @cython.no_gc
14+ cdef class nmod_mat_ctx:
15+ cdef nmod_t mod
16+ cdef bint _is_prime
17+ cdef nmod_ctx scalar_ctx
18+ cdef nmod_poly_ctx poly_ctx
19+
20+ @staticmethod
21+ cdef any_as_nmod_mat_ctx(obj)
22+ @staticmethod
23+ cdef nmod_mat_ctx _get_ctx(int mod)
24+ @staticmethod
25+ cdef nmod_mat_ctx _new_ctx(ulong mod)
526
6- from flint.types.nmod cimport nmod_ctx
27+ @cython.final
28+ cdef int any_as_nmod(self , mp_limb_t * val, obj) except - 1
29+ @cython.final
30+ cdef any_as_nmod_mat(self , obj)
31+ @cython.final
32+ cdef nmod new_nmod(self )
33+ @cython.final
34+ cdef nmod_poly new_nmod_poly(self )
35+ @cython.final
36+ cdef nmod_mat new_nmod_mat(self , ulong m, ulong n)
37+ @cython.final
38+ cdef nmod_mat new_nmod_mat_copy(self , nmod_mat other)
739
840
41+ @cython.no_gc
942cdef class nmod_mat(flint_mat):
1043 cdef nmod_mat_t val
11- cdef nmod_ctx ctx
44+ cdef nmod_mat_ctx ctx
1245
1346 cpdef long nrows(self )
1447 cpdef long ncols(self )
You can’t perform that action at this time.
0 commit comments