passagemath-ntl 10.6.33__cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-ntl might be problematic. Click here for more details.

Files changed (161) hide show
  1. passagemath_ntl-10.6.33.dist-info/METADATA +122 -0
  2. passagemath_ntl-10.6.33.dist-info/RECORD +161 -0
  3. passagemath_ntl-10.6.33.dist-info/WHEEL +6 -0
  4. passagemath_ntl-10.6.33.dist-info/top_level.txt +2 -0
  5. passagemath_ntl.libs/libgf2x-fbd36f80.so.3.0.0 +0 -0
  6. passagemath_ntl.libs/libgmp-93ebf16a.so.10.5.0 +0 -0
  7. passagemath_ntl.libs/libmpfi-ad12a86d.so.0.0.0 +0 -0
  8. passagemath_ntl.libs/libmpfr-e0f11cf3.so.6.2.1 +0 -0
  9. passagemath_ntl.libs/libntl-0043a3a2.so.44.0.1 +0 -0
  10. sage/all__sagemath_ntl.py +7 -0
  11. sage/libs/all__sagemath_ntl.py +3 -0
  12. sage/libs/mpfi/__init__.pxd +287 -0
  13. sage/libs/mpfi/types.pxd +10 -0
  14. sage/libs/ntl/GF2.pxd +18 -0
  15. sage/libs/ntl/GF2E.pxd +28 -0
  16. sage/libs/ntl/GF2EX.pxd +12 -0
  17. sage/libs/ntl/GF2X.pxd +81 -0
  18. sage/libs/ntl/ZZ.pxd +93 -0
  19. sage/libs/ntl/ZZX.pxd +85 -0
  20. sage/libs/ntl/ZZ_p.pxd +28 -0
  21. sage/libs/ntl/ZZ_pE.pxd +37 -0
  22. sage/libs/ntl/ZZ_pEX.pxd +106 -0
  23. sage/libs/ntl/ZZ_pX.pxd +122 -0
  24. sage/libs/ntl/__init__.py +4 -0
  25. sage/libs/ntl/all.py +72 -0
  26. sage/libs/ntl/conversion.pxd +106 -0
  27. sage/libs/ntl/convert.cpython-314t-aarch64-linux-gnu.so +0 -0
  28. sage/libs/ntl/convert.pxd +7 -0
  29. sage/libs/ntl/convert.pyx +38 -0
  30. sage/libs/ntl/decl.pxi +18 -0
  31. sage/libs/ntl/error.cpython-314t-aarch64-linux-gnu.so +0 -0
  32. sage/libs/ntl/error.pyx +63 -0
  33. sage/libs/ntl/lzz_p.pxd +20 -0
  34. sage/libs/ntl/lzz_pX.pxd +59 -0
  35. sage/libs/ntl/mat_GF2.pxd +30 -0
  36. sage/libs/ntl/mat_GF2E.pxd +30 -0
  37. sage/libs/ntl/mat_ZZ.pxd +59 -0
  38. sage/libs/ntl/misc.pxi +33 -0
  39. sage/libs/ntl/ntl_GF2.cpython-314t-aarch64-linux-gnu.so +0 -0
  40. sage/libs/ntl/ntl_GF2.pxd +5 -0
  41. sage/libs/ntl/ntl_GF2.pyx +281 -0
  42. sage/libs/ntl/ntl_GF2E.cpython-314t-aarch64-linux-gnu.so +0 -0
  43. sage/libs/ntl/ntl_GF2E.pxd +8 -0
  44. sage/libs/ntl/ntl_GF2E.pyx +488 -0
  45. sage/libs/ntl/ntl_GF2EContext.cpython-314t-aarch64-linux-gnu.so +0 -0
  46. sage/libs/ntl/ntl_GF2EContext.pxd +9 -0
  47. sage/libs/ntl/ntl_GF2EContext.pyx +134 -0
  48. sage/libs/ntl/ntl_GF2EX.cpython-314t-aarch64-linux-gnu.so +0 -0
  49. sage/libs/ntl/ntl_GF2EX.pxd +10 -0
  50. sage/libs/ntl/ntl_GF2EX.pyx +251 -0
  51. sage/libs/ntl/ntl_GF2X.cpython-314t-aarch64-linux-gnu.so +0 -0
  52. sage/libs/ntl/ntl_GF2X.pxd +5 -0
  53. sage/libs/ntl/ntl_GF2X.pyx +771 -0
  54. sage/libs/ntl/ntl_GF2X_linkage.pxi +404 -0
  55. sage/libs/ntl/ntl_ZZ.cpython-314t-aarch64-linux-gnu.so +0 -0
  56. sage/libs/ntl/ntl_ZZ.pxd +7 -0
  57. sage/libs/ntl/ntl_ZZ.pyx +541 -0
  58. sage/libs/ntl/ntl_ZZX.cpython-314t-aarch64-linux-gnu.so +0 -0
  59. sage/libs/ntl/ntl_ZZX.pxd +7 -0
  60. sage/libs/ntl/ntl_ZZX.pyx +1206 -0
  61. sage/libs/ntl/ntl_ZZ_p.cpython-314t-aarch64-linux-gnu.so +0 -0
  62. sage/libs/ntl/ntl_ZZ_p.pxd +10 -0
  63. sage/libs/ntl/ntl_ZZ_p.pyx +509 -0
  64. sage/libs/ntl/ntl_ZZ_pContext.cpython-314t-aarch64-linux-gnu.so +0 -0
  65. sage/libs/ntl/ntl_ZZ_pContext.pxd +22 -0
  66. sage/libs/ntl/ntl_ZZ_pContext.pyx +201 -0
  67. sage/libs/ntl/ntl_ZZ_pE.cpython-314t-aarch64-linux-gnu.so +0 -0
  68. sage/libs/ntl/ntl_ZZ_pE.pxd +11 -0
  69. sage/libs/ntl/ntl_ZZ_pE.pyx +349 -0
  70. sage/libs/ntl/ntl_ZZ_pEContext.cpython-314t-aarch64-linux-gnu.so +0 -0
  71. sage/libs/ntl/ntl_ZZ_pEContext.pxd +23 -0
  72. sage/libs/ntl/ntl_ZZ_pEContext.pyx +226 -0
  73. sage/libs/ntl/ntl_ZZ_pEX.cpython-314t-aarch64-linux-gnu.so +0 -0
  74. sage/libs/ntl/ntl_ZZ_pEX.pxd +10 -0
  75. sage/libs/ntl/ntl_ZZ_pEX.pyx +1255 -0
  76. sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi +420 -0
  77. sage/libs/ntl/ntl_ZZ_pX.cpython-314t-aarch64-linux-gnu.so +0 -0
  78. sage/libs/ntl/ntl_ZZ_pX.pxd +17 -0
  79. sage/libs/ntl/ntl_ZZ_pX.pyx +1532 -0
  80. sage/libs/ntl/ntl_lzz_p.cpython-314t-aarch64-linux-gnu.so +0 -0
  81. sage/libs/ntl/ntl_lzz_p.pxd +8 -0
  82. sage/libs/ntl/ntl_lzz_p.pyx +440 -0
  83. sage/libs/ntl/ntl_lzz_pContext.cpython-314t-aarch64-linux-gnu.so +0 -0
  84. sage/libs/ntl/ntl_lzz_pContext.pxd +7 -0
  85. sage/libs/ntl/ntl_lzz_pContext.pyx +137 -0
  86. sage/libs/ntl/ntl_lzz_pX.cpython-314t-aarch64-linux-gnu.so +0 -0
  87. sage/libs/ntl/ntl_lzz_pX.pxd +10 -0
  88. sage/libs/ntl/ntl_lzz_pX.pyx +902 -0
  89. sage/libs/ntl/ntl_mat_GF2.cpython-314t-aarch64-linux-gnu.so +0 -0
  90. sage/libs/ntl/ntl_mat_GF2.pxd +8 -0
  91. sage/libs/ntl/ntl_mat_GF2.pyx +612 -0
  92. sage/libs/ntl/ntl_mat_GF2E.cpython-314t-aarch64-linux-gnu.so +0 -0
  93. sage/libs/ntl/ntl_mat_GF2E.pxd +10 -0
  94. sage/libs/ntl/ntl_mat_GF2E.pyx +752 -0
  95. sage/libs/ntl/ntl_mat_ZZ.cpython-314t-aarch64-linux-gnu.so +0 -0
  96. sage/libs/ntl/ntl_mat_ZZ.pxd +6 -0
  97. sage/libs/ntl/ntl_mat_ZZ.pyx +1523 -0
  98. sage/libs/ntl/ntl_tools.pxd +3 -0
  99. sage/libs/ntl/ntlwrap.h +53 -0
  100. sage/libs/ntl/ntlwrap_impl.h +743 -0
  101. sage/libs/ntl/types.pxd +157 -0
  102. sage/libs/ntl/vec_GF2.pxd +26 -0
  103. sage/libs/ntl/vec_GF2E.pxd +2 -0
  104. sage/matrix/all__sagemath_ntl.py +1 -0
  105. sage/matrix/matrix_modn_dense_double.pxd +10 -0
  106. sage/matrix/matrix_modn_dense_float.pxd +9 -0
  107. sage/matrix/matrix_modn_dense_template.pxi +3257 -0
  108. sage/matrix/matrix_modn_dense_template_header.pxi +15 -0
  109. sage/matrix/matrix_modn_sparse.pxd +8 -0
  110. sage/misc/all__sagemath_ntl.py +1 -0
  111. sage/rings/all__sagemath_ntl.py +7 -0
  112. sage/rings/bernmm.cpython-314t-aarch64-linux-gnu.so +0 -0
  113. sage/rings/bernmm.pyx +161 -0
  114. sage/rings/bernoulli_mod_p.cpython-314t-aarch64-linux-gnu.so +0 -0
  115. sage/rings/bernoulli_mod_p.pyx +313 -0
  116. sage/rings/finite_rings/all__sagemath_ntl.py +1 -0
  117. sage/rings/finite_rings/finite_field_ntl_gf2e.py +305 -0
  118. sage/rings/finite_rings/residue_field_ntl_gf2e.cpython-314t-aarch64-linux-gnu.so +0 -0
  119. sage/rings/finite_rings/residue_field_ntl_gf2e.pyx +140 -0
  120. sage/rings/padics/all__sagemath_ntl.py +5 -0
  121. sage/rings/padics/padic_ZZ_pX_CA_element.cpython-314t-aarch64-linux-gnu.so +0 -0
  122. sage/rings/padics/padic_ZZ_pX_CA_element.pxd +25 -0
  123. sage/rings/padics/padic_ZZ_pX_CA_element.pyx +2368 -0
  124. sage/rings/padics/padic_ZZ_pX_CR_element.cpython-314t-aarch64-linux-gnu.so +0 -0
  125. sage/rings/padics/padic_ZZ_pX_CR_element.pxd +33 -0
  126. sage/rings/padics/padic_ZZ_pX_CR_element.pyx +3277 -0
  127. sage/rings/padics/padic_ZZ_pX_FM_element.cpython-314t-aarch64-linux-gnu.so +0 -0
  128. sage/rings/padics/padic_ZZ_pX_FM_element.pxd +12 -0
  129. sage/rings/padics/padic_ZZ_pX_FM_element.pyx +1739 -0
  130. sage/rings/padics/padic_ZZ_pX_element.cpython-314t-aarch64-linux-gnu.so +0 -0
  131. sage/rings/padics/padic_ZZ_pX_element.pxd +6 -0
  132. sage/rings/padics/padic_ZZ_pX_element.pyx +919 -0
  133. sage/rings/padics/padic_ext_element.cpython-314t-aarch64-linux-gnu.so +0 -0
  134. sage/rings/padics/padic_ext_element.pxd +38 -0
  135. sage/rings/padics/padic_ext_element.pyx +512 -0
  136. sage/rings/padics/pow_computer_ext.cpython-314t-aarch64-linux-gnu.so +0 -0
  137. sage/rings/padics/pow_computer_ext.pxd +107 -0
  138. sage/rings/padics/pow_computer_ext.pyx +2401 -0
  139. sage/rings/polynomial/all__sagemath_ntl.py +1 -0
  140. sage/rings/polynomial/evaluation_ntl.cpython-314t-aarch64-linux-gnu.so +0 -0
  141. sage/rings/polynomial/evaluation_ntl.pxd +7 -0
  142. sage/rings/polynomial/evaluation_ntl.pyx +70 -0
  143. sage/rings/polynomial/polynomial_gf2x.cpython-314t-aarch64-linux-gnu.so +0 -0
  144. sage/rings/polynomial/polynomial_gf2x.pxd +10 -0
  145. sage/rings/polynomial/polynomial_gf2x.pyx +364 -0
  146. sage/rings/polynomial/polynomial_integer_dense_ntl.cpython-314t-aarch64-linux-gnu.so +0 -0
  147. sage/rings/polynomial/polynomial_integer_dense_ntl.pxd +8 -0
  148. sage/rings/polynomial/polynomial_integer_dense_ntl.pyx +1128 -0
  149. sage/rings/polynomial/polynomial_modn_dense_ntl.cpython-314t-aarch64-linux-gnu.so +0 -0
  150. sage/rings/polynomial/polynomial_modn_dense_ntl.pxd +36 -0
  151. sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +2049 -0
  152. sage/rings/polynomial/polynomial_template.pxi +842 -0
  153. sage/rings/polynomial/polynomial_template_header.pxi +11 -0
  154. sage/rings/polynomial/polynomial_zz_pex.cpython-314t-aarch64-linux-gnu.so +0 -0
  155. sage/rings/polynomial/polynomial_zz_pex.pxd +12 -0
  156. sage/rings/polynomial/polynomial_zz_pex.pyx +778 -0
  157. sage/rings/real_mpfi.pxd +50 -0
  158. sage/schemes/all__sagemath_ntl.py +1 -0
  159. sage/schemes/hyperelliptic_curves/all__sagemath_ntl.py +1 -0
  160. sage/schemes/hyperelliptic_curves/hypellfrob.cpython-314t-aarch64-linux-gnu.so +0 -0
  161. sage/schemes/hyperelliptic_curves/hypellfrob.pyx +252 -0
@@ -0,0 +1,305 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # sage.doctest: needs sage.rings.finite_rings
3
+ """
4
+ Finite fields of characteristic 2
5
+ """
6
+
7
+ #*****************************************************************************
8
+ # Copyright (C) 2011 David Roe
9
+ # Copyright (C) 2012 Travis Scrimshaw
10
+ # Copyright (C) 2013 Peter Bruin
11
+ # Copyright (C) 2014 Jeroen Demeyer
12
+ #
13
+ # This program is free software: you can redistribute it and/or modify
14
+ # it under the terms of the GNU General Public License as published by
15
+ # the Free Software Foundation, either version 2 of the License, or
16
+ # (at your option) any later version.
17
+ # http://www.gnu.org/licenses/
18
+ #*****************************************************************************
19
+
20
+ from sage.rings.finite_rings.finite_field_base import FiniteField
21
+ from sage.libs.pari import pari
22
+ from sage.rings.integer import Integer
23
+
24
+
25
+ def late_import():
26
+ """
27
+ Imports various modules after startup.
28
+
29
+ EXAMPLES::
30
+
31
+ sage: sage.rings.finite_rings.finite_field_ntl_gf2e.late_import()
32
+ sage: sage.rings.finite_rings.finite_field_ntl_gf2e.GF2 is None # indirect doctest
33
+ False
34
+ """
35
+ if "GF2" in globals():
36
+ return
37
+ global Cache_ntl_gf2e, GF, GF2
38
+
39
+ import sage.rings.finite_rings.element_ntl_gf2e
40
+ Cache_ntl_gf2e = sage.rings.finite_rings.element_ntl_gf2e.Cache_ntl_gf2e
41
+
42
+ import sage.rings.finite_rings.finite_field_constructor
43
+ GF = sage.rings.finite_rings.finite_field_constructor.GF
44
+ GF2 = GF(2)
45
+
46
+
47
+ class FiniteField_ntl_gf2e(FiniteField):
48
+ """
49
+ Finite Field of characteristic 2 and order `2^n`.
50
+
51
+ INPUT:
52
+
53
+ - ``q`` -- `2^n` (must be 2 power)
54
+
55
+ - ``names`` -- variable used for poly_repr (default: ``'a'``)
56
+
57
+ - ``modulus`` -- a minimal polynomial to use for reduction
58
+
59
+ - ``repr`` -- controls the way elements are printed to the user:
60
+ (default: ``'poly'``)
61
+
62
+ - ``'poly'`` -- polynomial representation
63
+
64
+ OUTPUT: finite field with characteristic 2 and cardinality `2^n`
65
+
66
+ EXAMPLES::
67
+
68
+ sage: k.<a> = GF(2^16)
69
+ sage: type(k)
70
+ <class 'sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e_with_category'>
71
+ sage: k.<a> = GF(2^1024)
72
+ sage: k.modulus()
73
+ x^1024 + x^19 + x^6 + x + 1
74
+ sage: set_random_seed(6397)
75
+ sage: k.<a> = GF(2^17, modulus='random')
76
+ sage: k.modulus()
77
+ x^17 + x^16 + x^15 + x^10 + x^8 + x^6 + x^4 + x^3 + x^2 + x + 1
78
+ sage: k.modulus().is_irreducible()
79
+ True
80
+ sage: k.<a> = GF(2^211, modulus='minimal_weight')
81
+ sage: k.modulus()
82
+ x^211 + x^11 + x^10 + x^8 + 1
83
+ sage: k.<a> = GF(2^211, modulus='conway')
84
+ sage: k.modulus()
85
+ x^211 + x^9 + x^6 + x^5 + x^3 + x + 1
86
+ sage: k.<a> = GF(2^23, modulus='conway')
87
+ sage: a.multiplicative_order() == k.order() - 1
88
+ True
89
+ """
90
+
91
+ def __init__(self, q, names='a', modulus=None, repr='poly'):
92
+ """
93
+ Initialize ``self``.
94
+
95
+ TESTS::
96
+
97
+ sage: k.<a> = GF(2^100, modulus='strangeinput')
98
+ Traceback (most recent call last):
99
+ ...
100
+ ValueError: no such algorithm for finding an irreducible polynomial: strangeinput
101
+ sage: k.<a> = GF(2^20) ; type(k)
102
+ <class 'sage.rings.finite_rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e_with_category'>
103
+ sage: loads(dumps(k)) is k
104
+ True
105
+ sage: k1.<a> = GF(2^16)
106
+ sage: k2.<a> = GF(2^17)
107
+ sage: k1 == k2
108
+ False
109
+ sage: k3.<a> = GF(2^16, impl='pari_ffelt')
110
+ sage: k1 == k3
111
+ False
112
+
113
+ sage: TestSuite(k).run()
114
+
115
+ sage: k.<a> = GF(2^64)
116
+ sage: k._repr_option('element_is_atomic')
117
+ False
118
+ sage: P.<x> = PolynomialRing(k)
119
+ sage: (a+1)*x # indirect doctest
120
+ (a + 1)*x
121
+ """
122
+ late_import()
123
+ q = Integer(q)
124
+ if q < 2:
125
+ raise ValueError("q must be a 2-power")
126
+ k = q.exact_log(2)
127
+ if q != 1 << k:
128
+ raise ValueError("q must be a 2-power")
129
+ FiniteField.__init__(self, GF2, names, normalize=True)
130
+
131
+ from sage.rings.polynomial.polynomial_element import Polynomial
132
+ if not isinstance(modulus, Polynomial):
133
+ raise TypeError("modulus must be a polynomial")
134
+
135
+ self._cache = Cache_ntl_gf2e(self, k, modulus)
136
+ self._modulus = modulus
137
+
138
+ def characteristic(self):
139
+ """
140
+ Return the characteristic of ``self`` which is 2.
141
+
142
+ EXAMPLES::
143
+
144
+ sage: k.<a> = GF(2^16,modulus='random')
145
+ sage: k.characteristic()
146
+ 2
147
+ """
148
+ return Integer(2)
149
+
150
+ def order(self):
151
+ """
152
+ Return the cardinality of this field.
153
+
154
+ EXAMPLES::
155
+
156
+ sage: k.<a> = GF(2^64)
157
+ sage: k.order()
158
+ 18446744073709551616
159
+ """
160
+ return self._cache.order()
161
+
162
+ def degree(self):
163
+ r"""
164
+ If this field has cardinality `2^n` this method returns `n`.
165
+
166
+ EXAMPLES::
167
+
168
+ sage: k.<a> = GF(2^64)
169
+ sage: k.degree()
170
+ 64
171
+ """
172
+ return self._cache.degree()
173
+
174
+ def _element_constructor_(self, e):
175
+ """
176
+ Coerces several data types to ``self``.
177
+
178
+ INPUT:
179
+
180
+ - ``e`` -- data to coerce
181
+
182
+ EXAMPLES::
183
+
184
+ sage: k.<a> = GF(2^20)
185
+ sage: k(1) # indirect doctest
186
+ 1
187
+ sage: k(int(2))
188
+ 0
189
+
190
+ sage: k('a+1')
191
+ a + 1
192
+ sage: k('b+1')
193
+ Traceback (most recent call last):
194
+ ...
195
+ NameError: name 'b' is not defined
196
+
197
+ sage: R.<x>=GF(2)[]
198
+ sage: k(1+x+x^10+x^55)
199
+ a^19 + a^17 + a^16 + a^15 + a^12 + a^11 + a^8 + a^6 + a^4 + a^2 + 1
200
+
201
+ sage: V = k.vector_space(map=False)
202
+ sage: v = V.random_element()
203
+ sage: k(v) == sum(a^i if v[i] else 0 for i in range(len(v)))
204
+ True
205
+ sage: vector(k(v)) == v
206
+ True
207
+
208
+ sage: k(pari('Mod(1,2)*a^20'))
209
+ a^10 + a^9 + a^7 + a^6 + a^5 + a^4 + a + 1
210
+ """
211
+ return self._cache.import_data(e)
212
+
213
+ def gen(self, n=0):
214
+ r"""
215
+ Return a generator of ``self`` over its prime field, which is a
216
+ root of ``self.modulus()``.
217
+
218
+ INPUT:
219
+
220
+ - ``n`` -- must be 0
221
+
222
+ OUTPUT:
223
+
224
+ An element `a` of ``self`` such that ``self.modulus()(a) == 0``.
225
+
226
+ .. WARNING::
227
+
228
+ This generator is not guaranteed to be a generator for the
229
+ multiplicative group. To obtain the latter, use
230
+ :meth:`~sage.rings.finite_rings.finite_field_base.FiniteFields.multiplicative_generator()`
231
+ or use the ``modulus="primitive"`` option when constructing
232
+ the field.
233
+
234
+ EXAMPLES::
235
+
236
+ sage: k.<a> = GF(2^19)
237
+ sage: k.gen() == a
238
+ True
239
+ sage: a
240
+ a
241
+
242
+ TESTS::
243
+
244
+ sage: GF(2, impl='ntl').gen()
245
+ 1
246
+ sage: GF(2, impl='ntl', modulus=polygen(GF(2)) ).gen()
247
+ 0
248
+ sage: GF(2^19, 'a').gen(1)
249
+ Traceback (most recent call last):
250
+ ...
251
+ IndexError: only one generator
252
+ """
253
+ if n:
254
+ raise IndexError("only one generator")
255
+ return self._cache._gen
256
+
257
+ def prime_subfield(self):
258
+ r"""
259
+ Return the prime subfield `\GF{p}` of ``self`` if ``self`` is
260
+ `\GF{p^n}`.
261
+
262
+ EXAMPLES::
263
+
264
+ sage: F.<a> = GF(2^16)
265
+ sage: F.prime_subfield()
266
+ Finite Field of size 2
267
+ """
268
+ return GF2
269
+
270
+ def from_integer(self, number):
271
+ r"""
272
+ Given an integer `n` less than :meth:`cardinality` with base `2`
273
+ representation `a_0 + 2 \cdot a_1 + \cdots + 2^k a_k`, returns
274
+ `a_0 + a_1 \cdot x + \cdots + a_k x^k`, where `x` is the
275
+ generator of this finite field.
276
+
277
+ INPUT:
278
+
279
+ - ``number`` -- integer
280
+
281
+ EXAMPLES::
282
+
283
+ sage: k.<a> = GF(2^48)
284
+ sage: k.from_integer(2^43 + 2^15 + 1)
285
+ a^43 + a^15 + 1
286
+ sage: k.from_integer(33793)
287
+ a^15 + a^10 + 1
288
+ sage: 33793.digits(2) # little endian
289
+ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
290
+ """
291
+ return self._cache.fetch_int(number)
292
+
293
+ def _pari_modulus(self):
294
+ """
295
+ Return PARI object which is equivalent to the
296
+ polynomial/modulus of ``self``.
297
+
298
+ EXAMPLES::
299
+
300
+ sage: k1.<a> = GF(2^16)
301
+ sage: k1._pari_modulus()
302
+ Mod(1, 2)*a^16 + Mod(1, 2)*a^5 + Mod(1, 2)*a^3 + Mod(1, 2)*a^2 + Mod(1, 2)
303
+ """
304
+ f = pari(str(self.modulus()))
305
+ return f.subst('x', 'a') * pari("Mod(1,%s)" % self.characteristic())
@@ -0,0 +1,140 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # sage.doctest: needs sage.rings.finite_rings
3
+ r"""
4
+ Finite residue fields (NTL implementation)
5
+ """
6
+
7
+ # *****************************************************************************
8
+ # Copyright (C) 2007-2019 David Roe <roed@math.harvard.edu>
9
+ # 2007 William Stein <wstein@gmail.com>
10
+ # 2008 John Cremona
11
+ # 2008 Robert Bradshaw
12
+ # 2009 Nick Alexander
13
+ # 2010 Robert L. Miller
14
+ # 2010-2013 Simon King
15
+ # 2010-2017 Jeroen Demeyer
16
+ # 2012 Travis Scrimshaw
17
+ # 2016-2021 Frédéric Chapoton
18
+ # 2021-2022 Antonio Rojas
19
+ #
20
+ # This program is free software: you can redistribute it and/or modify
21
+ # it under the terms of the GNU General Public License as published by
22
+ # the Free Software Foundation, either version 2 of the License, or
23
+ # (at your option) any later version.
24
+ # http://www.gnu.org/licenses/
25
+ # *****************************************************************************
26
+
27
+ from sage.rings.finite_rings.finite_field_ntl_gf2e import FiniteField_ntl_gf2e
28
+ from sage.rings.finite_rings.residue_field import ResidueField_generic, ResidueFieldHomomorphism_global, ReductionMap
29
+
30
+
31
+ class ResidueFiniteField_ntl_gf2e(ResidueField_generic, FiniteField_ntl_gf2e):
32
+ """
33
+ The class representing residue fields with order a power of 2.
34
+
35
+ When the order is less than `2^16`, givaro is used by default instead.
36
+
37
+ EXAMPLES::
38
+
39
+ sage: # needs sage.rings.number_field
40
+ sage: R.<x> = QQ[]
41
+ sage: K.<a> = NumberField(x^3 - 7)
42
+ sage: P = K.ideal(29).factor()[0][0]
43
+ sage: k = K.residue_field(P)
44
+ sage: k.degree()
45
+ 2
46
+ sage: OK = K.maximal_order()
47
+ sage: c = OK(a)
48
+ sage: b = k(c)
49
+ sage: b*c^2
50
+ 7
51
+ sage: b*c
52
+ 13*abar + 5
53
+
54
+ sage: R.<t> = GF(2)[]; P = R.ideal(t^19 + t^5 + t^2 + t + 1)
55
+ sage: k.<a> = R.residue_field(P); type(k)
56
+ <class 'sage.rings.finite_rings.residue_field_ntl_gf2e.ResidueFiniteField_ntl_gf2e_with_category'>
57
+ sage: k(1/t)
58
+ a^18 + a^4 + a + 1
59
+ sage: k(1/t)*t
60
+ 1
61
+ """
62
+ # we change the order for consistency with FiniteField_ntl_gf2e's __cinit__
63
+ def __init__(self, q, name, modulus, repr, p, to_vs, to_order, PB):
64
+ r"""
65
+ INPUT:
66
+
67
+ - ``p`` -- the prime ideal defining this residue field
68
+
69
+ - ``q`` -- the order of this residue field
70
+
71
+ - ``name`` -- the name of the generator of this extension
72
+
73
+ - ``modulus`` -- the polynomial modulus for this extension
74
+
75
+ - ``to_vs`` -- the map from the number field (or function field) to
76
+ the appropriate vector space (over `\QQ` or `F_p(t)`)
77
+
78
+ - ``to_order`` -- the map from a lattice in that vector space to the
79
+ maximal order
80
+
81
+ - ``PB`` -- a matrix used in defining the reduction and lifting maps
82
+
83
+ EXAMPLES::
84
+
85
+ sage: R.<x> = QQ[]
86
+ sage: K.<a> = NumberField(x^4 + 3*x^2 - 17) # needs sage.rings.number_field
87
+ sage: P = K.ideal(61).factor()[0][0] # needs sage.rings.number_field
88
+ sage: k = K.residue_field(P) # needs sage.rings.number_field
89
+
90
+ sage: R.<t> = GF(3)[]; P = R.ideal(t^4 - t^3 + t + 1); k.<a> = P.residue_field()
91
+ sage: type(k) # needs sage.libs.linbox
92
+ <class 'sage.rings.finite_rings.residue_field_givaro.ResidueFiniteField_givaro_with_category'>
93
+ sage: a^5
94
+ a^3 + 2*a^2 + a + 2
95
+ """
96
+ ResidueField_generic.__init__(self, p)
97
+ FiniteField_ntl_gf2e.__init__(self, q, name, modulus, repr)
98
+ K = OK = p.ring()
99
+ if OK.is_field():
100
+ OK = OK.ring_of_integers()
101
+ else:
102
+ K = K.fraction_field()
103
+ if PB is None:
104
+ PBinv = None
105
+ else:
106
+ PBinv = PB**(-1)
107
+ self._populate_coercion_lists_(coerce_list=[self.base_ring(),
108
+ ResidueFieldHomomorphism_global(OK, self, to_vs, to_order, PB, PBinv)],
109
+ convert_list=[ReductionMap(K, self, to_vs, to_order, PB, PBinv)])
110
+
111
+ def _element_constructor_(self, x):
112
+ """
113
+ INPUT:
114
+
115
+ - ``x`` -- something to cast into ``self``
116
+
117
+ EXAMPLES::
118
+
119
+ sage: # needs sage.rings.number_field
120
+ sage: R.<x> = QQ[]
121
+ sage: K.<a> = NumberField(x^4 + 3*x^2 - 17)
122
+ sage: P = K.ideal(61).factor()[0][0]
123
+ sage: k = K.residue_field(P)
124
+ sage: k(77*a^7 + 4)
125
+ 2*abar + 4
126
+ sage: V = k.vector_space(map=False); v = V([3,-2])
127
+ sage: type(k.convert_map_from(V))
128
+ <class 'sage.structure.coerce_maps.DefaultConvertMap_unique'>
129
+ sage: k(v) # indirect doctest
130
+ 59*abar + 3
131
+
132
+ sage: R.<t> = GF(3)[]; P = R.ideal(t^4 - t^3 + t + 1); k.<a> = P.residue_field()
133
+ sage: V = k.vector_space(map=False); v = V([0,1,2,3])
134
+ sage: k(v) # indirect doctest
135
+ 2*a^2 + a
136
+ """
137
+ try:
138
+ return FiniteField_ntl_gf2e._element_constructor_(self, x)
139
+ except TypeError:
140
+ return ResidueField_generic._element_constructor_(self, x)
@@ -0,0 +1,5 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+
3
+ from sage.rings.padics.all__sagemath_categories import *
4
+
5
+ from sage.rings.padics.pow_computer_ext import PowComputer_ext_maker
@@ -0,0 +1,25 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.gmp.types cimport mpq_t
3
+ from sage.rings.padics.padic_ZZ_pX_element cimport pAdicZZpXElement
4
+ from sage.structure.element cimport RingElement, ModuleElement
5
+ from sage.libs.ntl.types cimport ZZ_pX_c
6
+ from sage.libs.ntl.ntl_ZZ_pX cimport ntl_ZZ_pX
7
+ from sage.rings.padics.padic_ZZ_pX_CR_element cimport pAdicZZpXCRElement
8
+
9
+ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
10
+ cdef ZZ_pX_c value
11
+ cdef long absprec
12
+
13
+ cdef bint _set_prec_both_with_ordp(self, long ordp, long absprec, long relprec) except -1
14
+ cdef int _set(self, ZZ_pX_c* value, long absprec) except -1
15
+ cdef int _set_from_mpq_part2(self, mpq_t x) except -1
16
+
17
+ cpdef pAdicZZpXCRElement to_fraction_field(self)
18
+ cdef pAdicZZpXCAElement _new_c(self, long absprec)
19
+ cdef pAdicZZpXCAElement _lshift_c(self, long n)
20
+ cdef pAdicZZpXCAElement _rshift_c(self, long n)
21
+ cpdef pAdicZZpXCAElement unit_part(self)
22
+ cpdef _ntl_rep_abs(self)
23
+ cpdef ntl_ZZ_pX _ntl_rep(self)
24
+
25
+ cpdef pAdicZZpXCAElement lift_to_precision(self, absprec=*)