summaryrefslogtreecommitdiff
path: root/libre/sagemath/linbox-1.4.patch
blob: 5897df763d0f01c335b9a1dcf8e617a8a538952a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
diff --git a/src/module_list.py b/src/module_list.py
index a49ed36..7798cb8 100644
--- a/src/module_list.py
+++ b/src/module_list.py
@@ -27,6 +27,18 @@ lapack_libs = list(lapack_pc['libraries'])
 lapack_library_dirs = list(lapack_pc['library_dirs'])
 lapack_include_dirs = list(lapack_pc['include_dirs'])
 
+# FFLAS-FFPACK
+fflas_ffpack_pc = pkgconfig.parse('fflas-ffpack')
+fflas_ffpack_libs = list(fflas_ffpack_pc['libraries'])
+fflas_ffpack_library_dirs = list(fflas_ffpack_pc['library_dirs'])
+fflas_ffpack_cflags = pkgconfig.cflags('fflas-ffpack').split()
+
+# Givaro
+givaro_pc = pkgconfig.parse('givaro')
+givaro_libs = list(givaro_pc['libraries'])
+givaro_library_dirs = list(givaro_pc['library_dirs'])
+givaro_cflags = pkgconfig.cflags('givaro').split()
+
 # GNU Scientific Library
 # Note we replace the built-in gslcblas with the above cblas
 gsl_pc = pkgconfig.parse('gsl')
@@ -40,6 +52,12 @@ gd_libs = list(gd_pc['libraries'])
 gd_library_dirs = list(gd_pc['library_dirs'])
 gd_include_dirs = list(gd_pc['include_dirs'])
 
+# LinBox
+linbox_pc = pkgconfig.parse('linbox')
+linbox_libs = list(linbox_pc['libraries'])
+linbox_library_dirs = list(linbox_pc['library_dirs'])
+linbox_cflags = pkgconfig.cflags('linbox').split()
+
 # PNG image library
 png_pc = pkgconfig.parse('libpng')
 png_libs = list(png_pc['libraries'])
@@ -58,9 +76,18 @@ zlib_include_dirs = list(zlib_pc['include_dirs'])
 #########################################################
 
 aliases = dict(
+    FFLASFFPACK_CFLAGS=fflas_ffpack_cflags,
+    FFLASFFPACK_LIBRARIES=fflas_ffpack_libs,
+    FFLASFFPACK_LIBDIR=fflas_ffpack_library_dirs,
+    GIVARO_CFLAGS=givaro_cflags,
+    GIVARO_LIBRARIES=givaro_libs,
+    GIVARO_LIBDIR=givaro_library_dirs,
     GSL_LIBRARIES=gsl_libs,
     GSL_LIBDIR=gsl_library_dirs,
     GSL_INCDIR=gsl_include_dirs,
+    LINBOX_CFLAGS=linbox_cflags,
+    LINBOX_LIBRARIES=linbox_libs,
+    LINBOX_LIBDIR=linbox_library_dirs,
 )
 
 #########################################################
@@ -85,12 +112,6 @@ except ValueError:
 singular_libs = ['singular', 'flint', 'ntl', 'gmpxx', 'gmp', 'readline', 'm']
 
 #########################################################
-### Givaro flags
-#########################################################
-
-givaro_extra_compile_args =['-D__STDC_LIMIT_MACROS']
-
-#########################################################
 ### Library order
 #########################################################
 
@@ -105,8 +126,7 @@ givaro_extra_compile_args =['-D__STDC_LIMIT_MACROS']
 # at the very end of the list.
 library_order_list = [
     "singular", "ec", "ecm",
-    "linboxsage", "ntl", "iml", "linbox", "givaro",
-] + gsl_libs + [
+] + linbox_libs  + gsl_libs + [
     "pari", "flint", "ratpoints", "ecl", "glpk", "ppl",
     "arb", "fplll", "mpfi", "mpfr", "mpc", "gmp", "gmpxx",
     "polybori",
@@ -593,13 +613,10 @@ ext_modules = [
 
     Extension('sage.libs.linbox.linbox',
               sources = ['sage/libs/linbox/linbox.pyx'],
-              libraries = ['linboxsage', 'ntl', 'iml', 'linbox',
-                           'givaro', 'mpfr', 'gmp', 'gmpxx'] + cblas_libs,
+              libraries = linbox_libs,
               language = 'c++',
               library_dirs = cblas_library_dirs,
-              include_dirs = cblas_include_dirs,
-              extra_compile_args = givaro_extra_compile_args,
-              depends = [os.path.join(SAGE_INC, 'givaro', 'givconfig.h')]),
+              include_dirs = cblas_include_dirs),
 
     Extension('sage.libs.lcalc.lcalc_Lfunction',
               sources = ['sage/libs/lcalc/lcalc_Lfunction.pyx'],
@@ -645,9 +662,8 @@ ext_modules = [
 
     Extension('sage.libs.singular.singular',
               sources = ['sage/libs/singular/singular.pyx'],
-              libraries = ['givaro'] + singular_libs,
-              language="c++",
-              extra_compile_args = givaro_extra_compile_args),
+              libraries = singular_libs,
+              language="c++"),
 
     Extension('sage.libs.singular.polynomial',
               sources = ['sage/libs/singular/polynomial.pyx'],
@@ -667,8 +683,7 @@ ext_modules = [
     Extension('sage.libs.singular.function',
               sources = ['sage/libs/singular/function.pyx'],
               libraries = singular_libs,
-              language="c++",
-              extra_compile_args = givaro_extra_compile_args),
+              language="c++"),
 
     Extension('sage.libs.singular.option',
               sources = ['sage/libs/singular/option.pyx'],
@@ -923,19 +938,17 @@ ext_modules = [
     Extension('sage.matrix.matrix_modn_dense_float',
               sources = ['sage/matrix/matrix_modn_dense_float.pyx'],
               language="c++",
-              libraries = ['ntl', 'linbox', 'givaro', 'mpfr', 'gmpxx', 'gmp'] + cblas_libs,
+              libraries = linbox_libs + cblas_libs,
               library_dirs = cblas_library_dirs,
-              include_dirs = cblas_include_dirs,
-              extra_compile_args = ['-DDISABLE_COMMENTATOR'] + givaro_extra_compile_args),
+              include_dirs = cblas_include_dirs),
 
     Extension('sage.matrix.matrix_modn_dense_double',
               sources = ['sage/matrix/matrix_modn_dense_double.pyx'],
               language="c++",
-              libraries = ['ntl', 'linbox', 'givaro', 'mpfr', 'gmpxx', 'gmp'] + cblas_libs,
+              libraries = linbox_libs + cblas_libs,
               library_dirs = cblas_library_dirs,
               include_dirs = cblas_include_dirs,
-              extra_compile_args = ["-D_XPG6", "-DDISABLE_COMMENTATOR"]
-                    + m4ri_extra_compile_args + givaro_extra_compile_args),
+              extra_compile_args = ["-D_XPG6"]),
 
     Extension('sage.matrix.matrix_modn_sparse',
               sources = ['sage/matrix/matrix_modn_sparse.pyx']),
@@ -1374,8 +1387,7 @@ ext_modules = [
     Extension('sage.rings.finite_rings.element_givaro',
               sources = ["sage/rings/finite_rings/element_givaro.pyx"],
               libraries = ['givaro', 'ntl', 'gmpxx', 'gmp', 'm'],
-              language='c++',
-              extra_compile_args = givaro_extra_compile_args),
+              language='c++'),
 
     Extension('sage.rings.finite_rings.element_ntl_gf2e',
               sources = ['sage/rings/finite_rings/element_ntl_gf2e.pyx'],
@@ -1395,8 +1407,7 @@ ext_modules = [
               sources = ["sage/rings/finite_rings/hom_finite_field_givaro.pyx"],
               # this order is needed to compile under windows.
               libraries = ['givaro', 'ntl', 'gmpxx', 'gmp', 'm'],
-              language='c++',
-              extra_compile_args = givaro_extra_compile_args),
+              language='c++'),
 
     ################################
     ##
@@ -1548,8 +1559,7 @@ ext_modules = [
     Extension('sage.rings.polynomial.plural',
               sources = ['sage/rings/polynomial/plural.pyx'],
               libraries = ['m', 'readline', 'singular', 'givaro', 'gmpxx', 'gmp'],
-              language="c++",
-              extra_compile_args = givaro_extra_compile_args),
+              language="c++"),
 
     Extension('sage.rings.polynomial.multi_polynomial_libsingular',
               sources = ['sage/rings/polynomial/multi_polynomial_libsingular.pyx'],
diff --git a/src/sage/libs/linbox/echelonform.pxd b/src/sage/libs/linbox/echelonform.pxd
index 3097c8b..cf4902d 100644
--- a/src/sage/libs/linbox/echelonform.pxd
+++ b/src/sage/libs/linbox/echelonform.pxd
@@ -1,23 +1,27 @@
+# distutils: extra_compile_args = LINBOX_CFLAGS
+# distutils: libraries = LINBOX_LIBRARIES
+# distutils: library_dirs = LINBOX_LIBDIR
+
 from sage.libs.linbox.modular cimport ModDoubleField, ModDoubleFieldElement, ModFloatField, ModFloatFieldElement
 from libc.stdint cimport uint64_t
 
-cdef extern from "linbox/matrix/blas-matrix.h" namespace "LinBox":
-    cdef cppclass BlasMatrixDouble "LinBox::BlasMatrix<LinBox::Modular<double> >":
+cdef extern from "linbox/matrix/dense-matrix.h" namespace "LinBox":
+    cdef cppclass BlasMatrixDouble "LinBox::DenseMatrix<Givaro::Modular<double> >":
         BlasMatrixDouble(ModDoubleField F, uint64_t nrows, uint64_t ncols)
         void setEntry(size_t i, size_t j, ModDoubleFieldElement t)
         ModDoubleFieldElement &getEntry(size_t i, size_t j)
 
-    cdef cppclass BlasMatrixFloat "LinBox::BlasMatrix<LinBox::Modular<float> >":
+    cdef cppclass BlasMatrixFloat "LinBox::DenseMatrix<Givaro::Modular<float> >":
         BlasMatrixFloat(ModFloatField F, uint64_t nrows, uint64_t ncols)
         void setEntry(size_t i, size_t j, ModFloatFieldElement t)
         ModFloatFieldElement &getEntry(size_t i, size_t j)
 
 cdef extern from "linbox/algorithms/echelon-form.h":
-    cdef cppclass EchelonFormDomainDouble "LinBox::EchelonFormDomain<LinBox::Modular<double> >":
+    cdef cppclass EchelonFormDomainDouble "LinBox::EchelonFormDomain<Givaro::Modular<double> >":
         EchelonFormDomainDouble(ModDoubleField)
         int rowReducedEchelon(BlasMatrixDouble, BlasMatrixDouble)
 
-    cdef cppclass EchelonFormDomainFloat "LinBox::EchelonFormDomain<LinBox::Modular<float> >":
+    cdef cppclass EchelonFormDomainFloat "LinBox::EchelonFormDomain<Givaro::Modular<float> >":
         EchelonFormDomainFloat(ModFloatField)
         int rowReducedEchelon(BlasMatrixFloat, BlasMatrixFloat)
 
diff --git a/src/sage/libs/linbox/fflas.pxd b/src/sage/libs/linbox/fflas.pxd
index e102004..01ab1b1 100644
--- a/src/sage/libs/linbox/fflas.pxd
+++ b/src/sage/libs/linbox/fflas.pxd
@@ -1,3 +1,7 @@
+# distutils: extra_compile_args = FFLASFFPACK_CFLAGS
+# distutils: libraries = FFLASFFPACK_LIBRARIES
+# distutils: library_dirs = FFLASFFPACK_LIBDIR
+
 from modular cimport ModDoubleField, ModFloatField, ModDoubleFieldElement, ModFloatFieldElement
 
 cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "std":
diff --git a/src/sage/libs/linbox/linbox.pyx b/src/sage/libs/linbox/linbox.pyx
index e932347..a9bd6d1 100644
--- a/src/sage/libs/linbox/linbox.pyx
+++ b/src/sage/libs/linbox/linbox.pyx
@@ -1,3 +1,7 @@
+# distutils: extra_compile_args = LINBOX_CFLAGS
+# distutils: libraries = LINBOX_LIBRARIES
+# distutils: library_dirs = LINBOX_LIBDIR
+
 r"""
 Linbox interface
 """
diff --git a/src/sage/libs/linbox/modular.pxd b/src/sage/libs/linbox/modular.pxd
index 7ef204c..ea5fb29 100644
--- a/src/sage/libs/linbox/modular.pxd
+++ b/src/sage/libs/linbox/modular.pxd
@@ -1,10 +1,10 @@
-cdef extern from "linbox/field/modular.h":
+cdef extern from "givaro/modular.h":
     # double
 
-    cdef cppclass ModDoubleFieldElement "LinBox::Modular<double>::Element":
+    cdef cppclass ModDoubleFieldElement "Givaro::Modular<double>::Element":
         pass
 
-    cdef cppclass ModDoubleField "LinBox::Modular<double>":
+    cdef cppclass ModDoubleField "Givaro::Modular<double>":
         ModDoubleField(int modulus)
         ModDoubleFieldElement init(ModDoubleFieldElement res, int v)
         ModDoubleFieldElement init(ModDoubleFieldElement res, double v)
@@ -20,10 +20,10 @@ cdef extern from "linbox/field/modular.h":
 
 
     # float
-    cdef cppclass ModFloatFieldElement "LinBox::Modular<float>::Element":
+    cdef cppclass ModFloatFieldElement "Givaro::Modular<float>::Element":
         pass
 
-    cdef cppclass ModFloatField "LinBox::Modular<float>":
+    cdef cppclass ModFloatField "Givaro::Modular<float>":
         ModFloatField(int modulus)
         ModFloatFieldElement init(ModFloatFieldElement res, int v)
         ModFloatFieldElement init(ModFloatFieldElement res, double v)
diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
index 33d7f7ec..77f6e0a 100644
--- a/src/sage/libs/singular/singular.pyx
+++ b/src/sage/libs/singular/singular.pyx
@@ -22,6 +22,7 @@ cdef extern from "limits.h":
 
 import os
 
+from libc.stdint cimport int64_t
 from sage.libs.singular.decl cimport intvec
 from sage.libs.singular.decl cimport SR_HDL, SR_INT, SR_TO_INT
 from sage.libs.singular.decl cimport singular_options, singular_verbose_options
@@ -155,7 +156,7 @@ cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache):
     order = cache.objectptr.cardinality() - 1
 
     while z:
-        c = cache.objectptr.initi(c, <long>napGetCoeff(z))
+        c = cache.objectptr.initi(c, <int64_t>napGetCoeff(z))
         e = napGetExpFrom(z,1, _ring)
         if e == 0:
             ret = cache.objectptr.add(ret, c, ret)
diff --git a/src/sage/rings/finite_rings/element_givaro.pxd b/src/sage/rings/finite_rings/element_givaro.pxd
index 68def46..91c4ed7 100644
--- a/src/sage/rings/finite_rings/element_givaro.pxd
+++ b/src/sage/rings/finite_rings/element_givaro.pxd
@@ -1,9 +1,15 @@
-from sage.structure.element cimport Element, RingElement, ModuleElement
-from sage.rings.finite_rings.element_base cimport FinitePolyExtElement
+# distutils: extra_compile_args = GIVARO_CFLAGS
+
+from libcpp.vector cimport vector
+ctypedef vector[int] intvec
+
+from libc.stdint cimport int64_t
 
-from sage.structure.parent  cimport Parent
+from sage.rings.finite_rings.element_base cimport FinitePolyExtElement
+from sage.structure.parent cimport Parent
 from sage.structure.sage_object cimport SageObject
 
+
 cdef extern from "givaro/givconfig.h":
     pass
 
@@ -13,16 +19,7 @@ cdef extern from "givaro/givrandom.h":
 
     GivRandom GivRandomSeeded  "Givaro::GivRandom"(unsigned long seed)
 
-cdef extern from "givaro/givgfq.h":
-    ctypedef struct intvec "std::vector<unsigned int>":
-        void (* push_back)(int elem)
-
-    ctypedef struct constintvec "const std::vector<unsigned int>"
-
-    intvec intvec_factory "std::vector<unsigned int>"(int len)
-
-cdef extern from "givaro/givgfq.h":
-
+cdef extern from "givaro/gfq.h":
     ctypedef struct GivaroGfq "Givaro::GFqDom<int>":
         #attributes
         unsigned int one
@@ -40,10 +37,10 @@ cdef extern from "givaro/givgfq.h":
         unsigned int (* cardinality)()
         int (* exponent)()
         int (* random)(GivRandom gen, int res)
-        int (* initi "init")(int res, int e)
+        int (* initi "init")(int res, int64_t e)
         int (* initd "init")(int res, double e)
         int (* indeterminate)()
-        int (* convert)(int r, int p)
+        int (* convert)(int64_t r, int p)
         int (* read)(int r, int p)
         int (* axpyin)(int r, int a, int x)
         int (* axpy)(int r, int a, int b, int c)
@@ -60,7 +57,12 @@ cdef extern from "givaro/givgfq.h":
     void delete "delete "(void *o)
     int gfq_element_factory "Givaro::GFqDom<int>::Element"()
 
-cdef class FiniteField_givaroElement(FinitePolyExtElement) #forward declaration
+
+cdef class FiniteField_givaroElement(FinitePolyExtElement):
+    cdef int element
+    cdef Cache_givaro _cache
+    cdef object _multiplicative_order
+    cdef FiniteField_givaroElement _new_c(self, int value)
 
 cdef class Cache_givaro(SageObject):
     cdef GivaroGfq *objectptr # C++ object
@@ -85,11 +87,4 @@ cdef class FiniteField_givaro_iterator:
     cdef int iterator
     cdef Cache_givaro _cache
 
-cdef class FiniteField_givaroElement(FinitePolyExtElement):
-    cdef int element
-    cdef Cache_givaro _cache
-    cdef object _multiplicative_order
-    cdef FiniteField_givaroElement _new_c(self, int value)
-
-
 cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x)
diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx
index d32b5cf..f2afa44 100644
--- a/src/sage/rings/finite_rings/element_givaro.pyx
+++ b/src/sage/rings/finite_rings/element_givaro.pyx
@@ -58,8 +58,9 @@ from sage.misc.randstate cimport randstate, current_randstate
 from sage.rings.finite_rings.finite_field_base cimport FiniteField
 from sage.rings.ring cimport Ring
 from element_ext_pari import FiniteField_ext_pariElement
-from element_pari_ffelt import FiniteFieldElement_pari_ffelt
+from element_pari_ffelt cimport FiniteFieldElement_pari_ffelt
 from sage.structure.sage_object cimport SageObject
+from sage.structure.element cimport Element, ModuleElement, RingElement
 import operator
 import sage.arith.all
 import finite_field_constructor as finite_field
@@ -373,18 +374,16 @@ cdef class Cache_givaro(SageObject):
         elif isinstance(e, int) or \
              isinstance(e, Integer) or \
              isinstance(e, long) or is_IntegerMod(e):
-            try:
-                e_int = e
-            except OverflowError:
-                e_int = e % self.characteristic()
+            e_int = e % self.characteristic()
             res = self.objectptr.initi(res, e_int)
 
         elif e is None:
             e_int = 0
-            res = self.objectptr.initi(res,e_int)
+            res = self.objectptr.initi(res, e_int)
 
         elif isinstance(e, float):
-            res = self.objectptr.initd(res,e)
+            e_int = int(e) % self.characteristic()
+            res = self.objectptr.initd(res, e_int)
 
         elif isinstance(e, str):
             return self.parent(eval(e.replace("^","**"),self.parent.gens_dict()))
@@ -394,8 +393,8 @@ cdef class Cache_givaro(SageObject):
                 raise TypeError, "e.parent must match self.vector_space"
             ret = self._zero_element
             for i in range(len(e)):
-                e_entry = e[i] % self.characteristic()
-                res = self.objectptr.initi(res, int(e_entry))
+                e_int = e[i] % self.characteristic()
+                res = self.objectptr.initi(res, e_int)
                 to_add = make_FiniteField_givaroElement(self, res)
                 ret = ret + to_add*self.parent.gen()**i
             return ret
@@ -434,8 +433,8 @@ cdef class Cache_givaro(SageObject):
                 raise ValueError, "list is too long"
             ret = self._zero_element
             for i in range(len(e)):
-                e_entry = e[i] % self.characteristic()
-                res = self.objectptr.initi(res, int(e_entry))
+                e_int = e[i] % self.characteristic()
+                res = self.objectptr.initi(res, e_int)
                 to_add = make_FiniteField_givaroElement(self, res)
                 ret = ret + to_add*self.parent.gen()**i
             return ret
@@ -572,19 +571,17 @@ cdef class Cache_givaro(SageObject):
         cdef int ret = k.zero
         cdef int a = k.indeterminate()
         cdef int at = k.one
-        cdef unsigned int ch = k.characteristic()
-        cdef int _n, t, i
+        cdef int ch = k.characteristic()
+        cdef int t, i
 
         if n<0 or n>k.cardinality():
             raise TypeError, "n must be between 0 and self.order()"
 
-        _n = n
-
         for i from 0 <= i < k.exponent():
-            t = k.initi(t, _n%ch)
+            t = k.initi(t, n % ch)
             ret = k.axpy(ret, t, at, ret)
             at = k.mul(at,at,a)
-            _n = _n/ch
+            n //= ch
         return make_FiniteField_givaroElement(self, ret)
 
     def _element_repr(self, FiniteField_givaroElement e):
diff --git a/src/sage/rings/finite_rings/finite_field_givaro.py b/src/sage/rings/finite_rings/finite_field_givaro.py
index adbaab3..c431f6d 100644
--- a/src/sage/rings/finite_rings/finite_field_givaro.py
+++ b/src/sage/rings/finite_rings/finite_field_givaro.py
@@ -269,7 +269,8 @@ class FiniteField_givaro(FiniteField):
             sage: k(2) # indirect doctest
             0
 
-            Floats coerce in:
+        Floats are converted like integers::
+
             sage: k(float(2.0))
             0
 
@@ -343,7 +344,7 @@ class FiniteField_givaro(FiniteField):
             sage: k(pari('Mod(1,2)'))
             1
             sage: k(pari('Mod(2,3)'))
-            0
+            a
             sage: k(pari('Mod(1,3)*a^20'))
             a^7 + a^5 + a^4 + a^2