passagemath-ntl 10.6.38__cp314-cp314-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 (162) hide show
  1. passagemath_ntl/__init__.py +3 -0
  2. passagemath_ntl-10.6.38.dist-info/METADATA +122 -0
  3. passagemath_ntl-10.6.38.dist-info/RECORD +162 -0
  4. passagemath_ntl-10.6.38.dist-info/WHEEL +6 -0
  5. passagemath_ntl-10.6.38.dist-info/top_level.txt +3 -0
  6. passagemath_ntl.libs/libgf2x-fbd36f80.so.3.0.0 +0 -0
  7. passagemath_ntl.libs/libgmp-93ebf16a.so.10.5.0 +0 -0
  8. passagemath_ntl.libs/libmpfi-ad12a86d.so.0.0.0 +0 -0
  9. passagemath_ntl.libs/libmpfr-9d41ebf1.so.6.2.1 +0 -0
  10. passagemath_ntl.libs/libntl-1bc30f7e.so.45.0.0 +0 -0
  11. sage/all__sagemath_ntl.py +7 -0
  12. sage/libs/all__sagemath_ntl.py +3 -0
  13. sage/libs/mpfi/__init__.pxd +287 -0
  14. sage/libs/mpfi/types.pxd +10 -0
  15. sage/libs/ntl/GF2.pxd +18 -0
  16. sage/libs/ntl/GF2E.pxd +28 -0
  17. sage/libs/ntl/GF2EX.pxd +12 -0
  18. sage/libs/ntl/GF2X.pxd +81 -0
  19. sage/libs/ntl/ZZ.pxd +93 -0
  20. sage/libs/ntl/ZZX.pxd +85 -0
  21. sage/libs/ntl/ZZ_p.pxd +28 -0
  22. sage/libs/ntl/ZZ_pE.pxd +37 -0
  23. sage/libs/ntl/ZZ_pEX.pxd +106 -0
  24. sage/libs/ntl/ZZ_pX.pxd +122 -0
  25. sage/libs/ntl/__init__.py +4 -0
  26. sage/libs/ntl/all.py +72 -0
  27. sage/libs/ntl/conversion.pxd +106 -0
  28. sage/libs/ntl/convert.cpython-314-aarch64-linux-gnu.so +0 -0
  29. sage/libs/ntl/convert.pxd +7 -0
  30. sage/libs/ntl/convert.pyx +38 -0
  31. sage/libs/ntl/decl.pxi +18 -0
  32. sage/libs/ntl/error.cpython-314-aarch64-linux-gnu.so +0 -0
  33. sage/libs/ntl/error.pyx +63 -0
  34. sage/libs/ntl/lzz_p.pxd +20 -0
  35. sage/libs/ntl/lzz_pX.pxd +59 -0
  36. sage/libs/ntl/mat_GF2.pxd +30 -0
  37. sage/libs/ntl/mat_GF2E.pxd +30 -0
  38. sage/libs/ntl/mat_ZZ.pxd +59 -0
  39. sage/libs/ntl/misc.pxi +33 -0
  40. sage/libs/ntl/ntl_GF2.cpython-314-aarch64-linux-gnu.so +0 -0
  41. sage/libs/ntl/ntl_GF2.pxd +5 -0
  42. sage/libs/ntl/ntl_GF2.pyx +281 -0
  43. sage/libs/ntl/ntl_GF2E.cpython-314-aarch64-linux-gnu.so +0 -0
  44. sage/libs/ntl/ntl_GF2E.pxd +8 -0
  45. sage/libs/ntl/ntl_GF2E.pyx +488 -0
  46. sage/libs/ntl/ntl_GF2EContext.cpython-314-aarch64-linux-gnu.so +0 -0
  47. sage/libs/ntl/ntl_GF2EContext.pxd +9 -0
  48. sage/libs/ntl/ntl_GF2EContext.pyx +134 -0
  49. sage/libs/ntl/ntl_GF2EX.cpython-314-aarch64-linux-gnu.so +0 -0
  50. sage/libs/ntl/ntl_GF2EX.pxd +10 -0
  51. sage/libs/ntl/ntl_GF2EX.pyx +251 -0
  52. sage/libs/ntl/ntl_GF2X.cpython-314-aarch64-linux-gnu.so +0 -0
  53. sage/libs/ntl/ntl_GF2X.pxd +5 -0
  54. sage/libs/ntl/ntl_GF2X.pyx +771 -0
  55. sage/libs/ntl/ntl_GF2X_linkage.pxi +404 -0
  56. sage/libs/ntl/ntl_ZZ.cpython-314-aarch64-linux-gnu.so +0 -0
  57. sage/libs/ntl/ntl_ZZ.pxd +7 -0
  58. sage/libs/ntl/ntl_ZZ.pyx +541 -0
  59. sage/libs/ntl/ntl_ZZX.cpython-314-aarch64-linux-gnu.so +0 -0
  60. sage/libs/ntl/ntl_ZZX.pxd +7 -0
  61. sage/libs/ntl/ntl_ZZX.pyx +1206 -0
  62. sage/libs/ntl/ntl_ZZ_p.cpython-314-aarch64-linux-gnu.so +0 -0
  63. sage/libs/ntl/ntl_ZZ_p.pxd +10 -0
  64. sage/libs/ntl/ntl_ZZ_p.pyx +509 -0
  65. sage/libs/ntl/ntl_ZZ_pContext.cpython-314-aarch64-linux-gnu.so +0 -0
  66. sage/libs/ntl/ntl_ZZ_pContext.pxd +22 -0
  67. sage/libs/ntl/ntl_ZZ_pContext.pyx +201 -0
  68. sage/libs/ntl/ntl_ZZ_pE.cpython-314-aarch64-linux-gnu.so +0 -0
  69. sage/libs/ntl/ntl_ZZ_pE.pxd +11 -0
  70. sage/libs/ntl/ntl_ZZ_pE.pyx +349 -0
  71. sage/libs/ntl/ntl_ZZ_pEContext.cpython-314-aarch64-linux-gnu.so +0 -0
  72. sage/libs/ntl/ntl_ZZ_pEContext.pxd +23 -0
  73. sage/libs/ntl/ntl_ZZ_pEContext.pyx +226 -0
  74. sage/libs/ntl/ntl_ZZ_pEX.cpython-314-aarch64-linux-gnu.so +0 -0
  75. sage/libs/ntl/ntl_ZZ_pEX.pxd +10 -0
  76. sage/libs/ntl/ntl_ZZ_pEX.pyx +1255 -0
  77. sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi +420 -0
  78. sage/libs/ntl/ntl_ZZ_pX.cpython-314-aarch64-linux-gnu.so +0 -0
  79. sage/libs/ntl/ntl_ZZ_pX.pxd +17 -0
  80. sage/libs/ntl/ntl_ZZ_pX.pyx +1532 -0
  81. sage/libs/ntl/ntl_lzz_p.cpython-314-aarch64-linux-gnu.so +0 -0
  82. sage/libs/ntl/ntl_lzz_p.pxd +8 -0
  83. sage/libs/ntl/ntl_lzz_p.pyx +440 -0
  84. sage/libs/ntl/ntl_lzz_pContext.cpython-314-aarch64-linux-gnu.so +0 -0
  85. sage/libs/ntl/ntl_lzz_pContext.pxd +7 -0
  86. sage/libs/ntl/ntl_lzz_pContext.pyx +137 -0
  87. sage/libs/ntl/ntl_lzz_pX.cpython-314-aarch64-linux-gnu.so +0 -0
  88. sage/libs/ntl/ntl_lzz_pX.pxd +10 -0
  89. sage/libs/ntl/ntl_lzz_pX.pyx +902 -0
  90. sage/libs/ntl/ntl_mat_GF2.cpython-314-aarch64-linux-gnu.so +0 -0
  91. sage/libs/ntl/ntl_mat_GF2.pxd +8 -0
  92. sage/libs/ntl/ntl_mat_GF2.pyx +612 -0
  93. sage/libs/ntl/ntl_mat_GF2E.cpython-314-aarch64-linux-gnu.so +0 -0
  94. sage/libs/ntl/ntl_mat_GF2E.pxd +10 -0
  95. sage/libs/ntl/ntl_mat_GF2E.pyx +752 -0
  96. sage/libs/ntl/ntl_mat_ZZ.cpython-314-aarch64-linux-gnu.so +0 -0
  97. sage/libs/ntl/ntl_mat_ZZ.pxd +6 -0
  98. sage/libs/ntl/ntl_mat_ZZ.pyx +1523 -0
  99. sage/libs/ntl/ntl_tools.pxd +3 -0
  100. sage/libs/ntl/ntlwrap.h +53 -0
  101. sage/libs/ntl/ntlwrap_impl.h +743 -0
  102. sage/libs/ntl/types.pxd +157 -0
  103. sage/libs/ntl/vec_GF2.pxd +26 -0
  104. sage/libs/ntl/vec_GF2E.pxd +2 -0
  105. sage/matrix/all__sagemath_ntl.py +1 -0
  106. sage/matrix/matrix_modn_dense_double.pxd +10 -0
  107. sage/matrix/matrix_modn_dense_float.pxd +9 -0
  108. sage/matrix/matrix_modn_dense_template.pxi +3257 -0
  109. sage/matrix/matrix_modn_dense_template_header.pxi +15 -0
  110. sage/matrix/matrix_modn_sparse.pxd +8 -0
  111. sage/misc/all__sagemath_ntl.py +1 -0
  112. sage/rings/all__sagemath_ntl.py +7 -0
  113. sage/rings/bernmm.cpython-314-aarch64-linux-gnu.so +0 -0
  114. sage/rings/bernmm.pyx +161 -0
  115. sage/rings/bernoulli_mod_p.cpython-314-aarch64-linux-gnu.so +0 -0
  116. sage/rings/bernoulli_mod_p.pyx +313 -0
  117. sage/rings/finite_rings/all__sagemath_ntl.py +1 -0
  118. sage/rings/finite_rings/finite_field_ntl_gf2e.py +305 -0
  119. sage/rings/finite_rings/residue_field_ntl_gf2e.cpython-314-aarch64-linux-gnu.so +0 -0
  120. sage/rings/finite_rings/residue_field_ntl_gf2e.pyx +140 -0
  121. sage/rings/padics/all__sagemath_ntl.py +5 -0
  122. sage/rings/padics/padic_ZZ_pX_CA_element.cpython-314-aarch64-linux-gnu.so +0 -0
  123. sage/rings/padics/padic_ZZ_pX_CA_element.pxd +25 -0
  124. sage/rings/padics/padic_ZZ_pX_CA_element.pyx +2368 -0
  125. sage/rings/padics/padic_ZZ_pX_CR_element.cpython-314-aarch64-linux-gnu.so +0 -0
  126. sage/rings/padics/padic_ZZ_pX_CR_element.pxd +33 -0
  127. sage/rings/padics/padic_ZZ_pX_CR_element.pyx +3277 -0
  128. sage/rings/padics/padic_ZZ_pX_FM_element.cpython-314-aarch64-linux-gnu.so +0 -0
  129. sage/rings/padics/padic_ZZ_pX_FM_element.pxd +12 -0
  130. sage/rings/padics/padic_ZZ_pX_FM_element.pyx +1739 -0
  131. sage/rings/padics/padic_ZZ_pX_element.cpython-314-aarch64-linux-gnu.so +0 -0
  132. sage/rings/padics/padic_ZZ_pX_element.pxd +6 -0
  133. sage/rings/padics/padic_ZZ_pX_element.pyx +919 -0
  134. sage/rings/padics/padic_ext_element.cpython-314-aarch64-linux-gnu.so +0 -0
  135. sage/rings/padics/padic_ext_element.pxd +38 -0
  136. sage/rings/padics/padic_ext_element.pyx +512 -0
  137. sage/rings/padics/pow_computer_ext.cpython-314-aarch64-linux-gnu.so +0 -0
  138. sage/rings/padics/pow_computer_ext.pxd +107 -0
  139. sage/rings/padics/pow_computer_ext.pyx +2401 -0
  140. sage/rings/polynomial/all__sagemath_ntl.py +1 -0
  141. sage/rings/polynomial/evaluation_ntl.cpython-314-aarch64-linux-gnu.so +0 -0
  142. sage/rings/polynomial/evaluation_ntl.pxd +7 -0
  143. sage/rings/polynomial/evaluation_ntl.pyx +70 -0
  144. sage/rings/polynomial/polynomial_gf2x.cpython-314-aarch64-linux-gnu.so +0 -0
  145. sage/rings/polynomial/polynomial_gf2x.pxd +10 -0
  146. sage/rings/polynomial/polynomial_gf2x.pyx +364 -0
  147. sage/rings/polynomial/polynomial_integer_dense_ntl.cpython-314-aarch64-linux-gnu.so +0 -0
  148. sage/rings/polynomial/polynomial_integer_dense_ntl.pxd +8 -0
  149. sage/rings/polynomial/polynomial_integer_dense_ntl.pyx +1128 -0
  150. sage/rings/polynomial/polynomial_modn_dense_ntl.cpython-314-aarch64-linux-gnu.so +0 -0
  151. sage/rings/polynomial/polynomial_modn_dense_ntl.pxd +36 -0
  152. sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +2049 -0
  153. sage/rings/polynomial/polynomial_template.pxi +842 -0
  154. sage/rings/polynomial/polynomial_template_header.pxi +11 -0
  155. sage/rings/polynomial/polynomial_zz_pex.cpython-314-aarch64-linux-gnu.so +0 -0
  156. sage/rings/polynomial/polynomial_zz_pex.pxd +12 -0
  157. sage/rings/polynomial/polynomial_zz_pex.pyx +778 -0
  158. sage/rings/real_mpfi.pxd +50 -0
  159. sage/schemes/all__sagemath_ntl.py +1 -0
  160. sage/schemes/hyperelliptic_curves/all__sagemath_ntl.py +1 -0
  161. sage/schemes/hyperelliptic_curves/hypellfrob.cpython-314-aarch64-linux-gnu.so +0 -0
  162. sage/schemes/hyperelliptic_curves/hypellfrob.pyx +252 -0
@@ -0,0 +1,420 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # sage.doctest: needs sage.rings.finite_rings
3
+ r"""
4
+ Linkage for arithmetic with NTL's ZZ_pEX elements.
5
+
6
+ This file provides the backend for \class{Polynomial_ZZ_pEX} via
7
+ templating.
8
+
9
+ AUTHOR:
10
+ -- Yann Laigle-Chapuy (2010-01): initial version
11
+ """
12
+
13
+ #*****************************************************************************
14
+ # Copyright (C) 2010 Yann Laigle-Chapuy
15
+ #
16
+ # This program is free software: you can redistribute it and/or modify
17
+ # it under the terms of the GNU General Public License as published by
18
+ # the Free Software Foundation, either version 2 of the License, or
19
+ # (at your option) any later version.
20
+ # http://www.gnu.org/licenses/
21
+ #*****************************************************************************
22
+
23
+ from cysignals.signals cimport sig_on, sig_off
24
+
25
+ from sage.libs.ntl.ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class
26
+ from sage.libs.ntl.ZZ_pEX cimport *
27
+ from sage.libs.ntl.ntl_ZZ_pE cimport ntl_ZZ_pE
28
+ from sage.libs.ntl.types cimport ZZ_pX_c, ZZ_pEX_c
29
+
30
+ cdef ZZ_pEX_c *celement_new(cparent parent) noexcept:
31
+ """
32
+ EXAMPLES::
33
+
34
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
35
+ """
36
+ if parent != NULL:
37
+ parent[0].zzpc[0].restore()
38
+ parent[0].zzpec[0].restore()
39
+ return new ZZ_pEX_c()
40
+
41
+ cdef int celement_delete(ZZ_pEX_c *e, cparent parent) noexcept:
42
+ """
43
+ EXAMPLES::
44
+
45
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
46
+ sage: del x
47
+ """
48
+ if parent != NULL:
49
+ parent[0].zzpc[0].restore()
50
+ parent[0].zzpec[0].restore()
51
+ del e
52
+
53
+ cdef int celement_construct(ZZ_pEX_c *e, cparent parent) noexcept:
54
+ """
55
+ EXAMPLES::
56
+
57
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
58
+ """
59
+ if parent != NULL:
60
+ parent[0].zzpc[0].restore()
61
+ parent[0].zzpec[0].restore()
62
+
63
+ cdef int celement_destruct(ZZ_pEX_c *e, cparent parent) noexcept:
64
+ """
65
+ EXAMPLES::
66
+
67
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
68
+ sage: del x
69
+ """
70
+ # do not call restore here
71
+ # 1) the NTL context might have already been destroyed when exiting Python
72
+ # 2) you better not make any NTL calls after destruct, no need to set the context
73
+
74
+ cdef int celement_gen(ZZ_pEX_c *e, long i, cparent parent) except -2:
75
+ """
76
+ EXAMPLES::
77
+
78
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
79
+ """
80
+ if parent != NULL:
81
+ parent[0].zzpc[0].restore()
82
+ parent[0].zzpec[0].restore()
83
+ ZZ_pEX_SetX(e[0])
84
+
85
+ cdef object celement_repr(ZZ_pEX_c *e, cparent parent):
86
+ """
87
+ We ignore NTL's printing.
88
+
89
+ EXAMPLES::
90
+
91
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
92
+ sage: x
93
+ x
94
+ """
95
+ raise NotImplementedError
96
+
97
+ cdef inline int celement_set(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except -2:
98
+ """
99
+ EXAMPLES::
100
+
101
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
102
+ sage: y = x
103
+ sage: y
104
+ x
105
+ """
106
+ res[0] = a[0]
107
+
108
+ cdef inline int celement_set_si(ZZ_pEX_c* res, long i, cparent parent) except -2:
109
+ """
110
+ EXAMPLES::
111
+
112
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
113
+ sage: P(0)
114
+ 0
115
+ sage: P(17)
116
+ 17
117
+ sage: P(next_prime(2**60))
118
+ 0
119
+ """
120
+ if parent != NULL:
121
+ parent[0].zzpc[0].restore()
122
+ parent[0].zzpec[0].restore()
123
+ ZZ_pEX_SetCoeff_long(res[0], 0, i)
124
+
125
+ cdef inline long celement_get_si(ZZ_pEX_c* res, cparent parent) except -2:
126
+ raise NotImplementedError
127
+
128
+ cdef inline bint celement_is_zero(ZZ_pEX_c* a, cparent parent) except -2:
129
+ """
130
+ EXAMPLES::
131
+
132
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
133
+ sage: bool(x), x.is_zero()
134
+ (True, False)
135
+ sage: bool(P(0)), P(0).is_zero()
136
+ (False, True)
137
+ """
138
+ return ZZ_pEX_IsZero(a[0])
139
+
140
+ cdef inline bint celement_is_one(ZZ_pEX_c *a, cparent parent) except -2:
141
+ """
142
+ EXAMPLES::
143
+
144
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
145
+ sage: x.is_one()
146
+ False
147
+ sage: P(1).is_one()
148
+ True
149
+ """
150
+ if parent != NULL:
151
+ parent[0].zzpc[0].restore()
152
+ parent[0].zzpec[0].restore()
153
+ return ZZ_pEX_IsOne(a[0])
154
+
155
+ cdef inline bint celement_equal(ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2:
156
+ """
157
+ EXAMPLES::
158
+
159
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
160
+ sage: x == x
161
+ True
162
+ sage: y = x; x == y
163
+ True
164
+ sage: x^2 + 1 == x^2 + x
165
+ False
166
+ """
167
+ if parent != NULL:
168
+ parent[0].zzpc[0].restore()
169
+ parent[0].zzpec[0].restore()
170
+ return a[0] == b[0]
171
+
172
+ cdef inline int celement_cmp(ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2:
173
+ """
174
+ Not used.
175
+
176
+ Comparison is implemented in
177
+ ``sage/rings/polynomial/polynomial_zz_pex.pyx`` instead.
178
+ """
179
+ raise NotImplementedError
180
+
181
+ cdef long celement_len(ZZ_pEX_c *a, cparent parent) except -2:
182
+ """
183
+ EXAMPLES::
184
+
185
+ sage: P.<x> = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL')
186
+ sage: x.degree()
187
+ 1
188
+ sage: (x+1).degree()
189
+ 1
190
+ """
191
+ if parent != NULL:
192
+ parent[0].zzpc[0].restore()
193
+ parent[0].zzpec[0].restore()
194
+ return int(ZZ_pEX_deg(a[0]))+1
195
+
196
+ cdef inline int celement_add(ZZ_pEX_c *res, ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2:
197
+ """
198
+ EXAMPLES::
199
+
200
+ sage: K.<a> = GF(next_prime(2**60)**3)
201
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
202
+ sage: (1+a+a^2)*x + (1+x+x^2)
203
+ x^2 + (a^2 + a + 2)*x + 1
204
+ """
205
+ if parent != NULL:
206
+ parent[0].zzpc[0].restore()
207
+ parent[0].zzpec[0].restore()
208
+ ZZ_pEX_add(res[0], a[0], b[0])
209
+
210
+ cdef inline int celement_sub(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
211
+ """
212
+ EXAMPLES::
213
+
214
+ sage: K.<a> = GF(next_prime(2**60)**3)
215
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
216
+ sage: (1+a+a^2)*x - (1+x+x^2)
217
+ 1152921504606847008*x^2 + (a^2 + a)*x + 1152921504606847008
218
+ """
219
+ if parent != NULL:
220
+ parent[0].zzpc[0].restore()
221
+ parent[0].zzpec[0].restore()
222
+ ZZ_pEX_sub(res[0], a[0], b[0])
223
+
224
+ cdef inline int celement_neg(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except -2:
225
+ """
226
+ EXAMPLES::
227
+
228
+ sage: K.<a> = GF(next_prime(2**60)**3)
229
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
230
+ sage: -x
231
+ 1152921504606847008*x
232
+ """
233
+ if parent != NULL:
234
+ parent[0].zzpc[0].restore()
235
+ parent[0].zzpec[0].restore()
236
+ ZZ_pEX_negate(res[0], a[0])
237
+
238
+ cdef inline int celement_mul_scalar(ZZ_pEX_c* res, ZZ_pEX_c* p, object c, cparent parent) except -1:
239
+ raise NotImplementedError
240
+
241
+ cdef inline int celement_mul(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
242
+ """
243
+ EXAMPLES::
244
+
245
+ sage: K.<a> = GF(next_prime(2**60)**3)
246
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
247
+ sage: (1+a+a^2)*x * (1+x+x^2)
248
+ (a^2 + a + 1)*x^3 + (a^2 + a + 1)*x^2 + (a^2 + a + 1)*x
249
+ """
250
+ if parent != NULL:
251
+ parent[0].zzpc[0].restore()
252
+ parent[0].zzpec[0].restore()
253
+ ZZ_pEX_mul(res[0], a[0], b[0])
254
+
255
+ cdef inline int celement_truncate(ZZ_pEX_c* res, ZZ_pEX_c* a, long len, cparent parent) except -2:
256
+ """
257
+ EXAMPLES::
258
+
259
+ sage: K.<a> = GF(next_prime(2**60)**3)
260
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
261
+ sage: p = (a^2 + 1)*x^3 + (a + 1)*x^2 + (a^2 + a + 1)*x + a
262
+ sage: p.truncate(2) # indirect doctest
263
+ (a^2 + a + 1)*x + a
264
+ """
265
+ ZZ_pEX_trunc(res[0], a[0], len)
266
+
267
+ cdef inline int celement_div(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
268
+ if parent != NULL:
269
+ parent[0].zzpc[0].restore()
270
+ parent[0].zzpec[0].restore()
271
+ return ZZ_pEX_divide(res[0], a[0], b[0])
272
+
273
+ cdef inline int celement_floordiv(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
274
+ """
275
+ EXAMPLES::
276
+
277
+ sage: K.<a> = GF(next_prime(2**60)**3)
278
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
279
+ sage: (x^2+2*a*x+a^2)//(x+a)
280
+ x + a
281
+ sage: (x^2+2*a*x)//(x+a)
282
+ x + a
283
+ sage: x//(x+1)
284
+ 1
285
+ sage: (x+1)//x
286
+ 1
287
+ """
288
+ if parent != NULL:
289
+ parent[0].zzpc[0].restore()
290
+ parent[0].zzpec[0].restore()
291
+ ZZ_pEX_div_ZZ_pEX(res[0], a[0], b[0])
292
+
293
+ cdef inline int celement_mod(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
294
+ """
295
+ EXAMPLES::
296
+
297
+ sage: K.<a> = GF(next_prime(2**60)**3)
298
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
299
+ sage: (x^2-2*a*x) % (x+a)
300
+ 3*a^2
301
+ """
302
+ if parent != NULL:
303
+ parent[0].zzpc[0].restore()
304
+ parent[0].zzpec[0].restore()
305
+ ZZ_pEX_rem(res[0], a[0], b[0])
306
+
307
+ cdef inline int celement_quorem(ZZ_pEX_c* q, ZZ_pEX_c* r, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2:
308
+ """
309
+ EXAMPLES::
310
+
311
+ sage: K.<a> = GF(next_prime(2**60)**3)
312
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
313
+ sage: (x^2+2*a*x).quo_rem(x-a)
314
+ (x + 3*a, 3*a^2)
315
+ """
316
+ if parent != NULL:
317
+ parent[0].zzpc[0].restore()
318
+ parent[0].zzpec[0].restore()
319
+ ZZ_pEX_DivRem(q[0], r[0], a[0], b[0])
320
+
321
+ cdef inline int celement_inv(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except -2:
322
+ raise NotImplementedError
323
+
324
+ cdef inline int celement_pow(ZZ_pEX_c* res, ZZ_pEX_c* x, long e, ZZ_pEX_c *modulus, cparent parent) except -2:
325
+ """
326
+ EXAMPLES::
327
+
328
+ sage: K.<a> = GF(next_prime(2**60)**3)
329
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
330
+ sage: x^1000
331
+ x^1000
332
+ sage: (x+1)^2
333
+ x^2 + 2*x + 1
334
+ sage: (x+1)^(-2)
335
+ 1/(x^2 + 2*x + 1)
336
+ sage: f = x+(a+1)
337
+ sage: f**50 == sum(binomial(50,i)*(a+1)**i*x**(50-i) for i in range(51)) # needs sage.symbolic
338
+ True
339
+
340
+ TESTS:
341
+
342
+ Check that :issue:`15777` is fixed::
343
+
344
+ sage: k.<t> = GF(5**5)
345
+ sage: x = polygen(k)
346
+ sage: pow(x+1,100,x)
347
+ 1
348
+ sage: pow(x+2,3,x)
349
+ 3
350
+ sage: pow(x**3+1,2,x**2+2)
351
+ x + 3
352
+ sage: pow(x**3+1,10**7,x**2+2)
353
+ x + 2
354
+ """
355
+ if parent != NULL:
356
+ parent[0].zzpc[0].restore()
357
+ parent[0].zzpec[0].restore()
358
+
359
+ cdef ZZ_pEX_Modulus_c mod
360
+ cdef ZZ_pEX_c y
361
+ if modulus == NULL:
362
+ if ZZ_pEX_IsX(x[0]):
363
+ sig_on()
364
+ ZZ_pEX_LeftShift(res[0], x[0], e - 1)
365
+ sig_off()
366
+ else:
367
+ sig_on()
368
+ ZZ_pEX_power(res[0], x[0], e)
369
+ sig_off()
370
+ else:
371
+ if ZZ_pEX_deg(modulus[0]) == 1:
372
+ ZZ_pEX_rem(y, x[0], modulus[0])
373
+ sig_on()
374
+ ZZ_pEX_power(res[0], y, e)
375
+ sig_off()
376
+ return 0
377
+ ZZ_pEX_Modulus_build(mod, modulus[0])
378
+ if ZZ_pEX_deg(x[0]) < ZZ_pEX_deg(modulus[0]):
379
+ sig_on()
380
+ ZZ_pEX_PowerMod_pre(res[0], x[0], e, mod)
381
+ sig_off()
382
+ else:
383
+ ZZ_pEX_rem_pre(y, x[0], mod)
384
+ sig_on()
385
+ ZZ_pEX_PowerMod_pre(res[0], y, e, mod)
386
+ sig_off()
387
+
388
+ cdef inline int celement_gcd(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c *b, cparent parent) except -2:
389
+ """
390
+ EXAMPLES::
391
+
392
+ sage: K.<a> = GF(next_prime(2**60)**3)
393
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
394
+ sage: f = (x+3)*(x^7+a*x^5+1)
395
+ sage: f.gcd(x+3)
396
+ x + 3
397
+ sage: f.gcd(x+4)
398
+ 1
399
+ """
400
+ if parent != NULL:
401
+ parent[0].zzpc[0].restore()
402
+ parent[0].zzpec[0].restore()
403
+ ZZ_pEX_GCD(res[0], a[0], b[0])
404
+
405
+ cdef inline int celement_xgcd(ZZ_pEX_c* res, ZZ_pEX_c* s, ZZ_pEX_c *t, ZZ_pEX_c* a, ZZ_pEX_c *b, cparent parent) except -2:
406
+ """
407
+ EXAMPLES::
408
+
409
+ sage: K.<a> = GF(next_prime(2**60)**3)
410
+ sage: P.<x> = PolynomialRing(K,implementation='NTL')
411
+ sage: f = (x+3)*(x^7+a*x^5+1)
412
+ sage: f.xgcd(x+3)
413
+ (x + 3, 0, 1)
414
+ sage: (a+1+x).xgcd(a+x)
415
+ (1, 1, 1152921504606847008)
416
+ """
417
+ if parent != NULL:
418
+ parent[0].zzpc[0].restore()
419
+ parent[0].zzpec[0].restore()
420
+ ZZ_pEX_XGCD(res[0], s[0], t[0], a[0], b[0])
@@ -0,0 +1,17 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.ZZ_pX cimport *
3
+ from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class
4
+ from sage.rings.integer cimport Integer
5
+
6
+ cdef class ntl_ZZ_pX():
7
+ cdef ZZ_pX_c x
8
+ cdef ntl_ZZ_pContext_class c
9
+ cdef void setitem_from_int(ntl_ZZ_pX self, long i, int value) noexcept
10
+ cdef int getitem_as_int(ntl_ZZ_pX self, long i) noexcept
11
+ cdef ntl_ZZ_pX _new(self)
12
+ cdef ntl_ZZ_pX _pow(ntl_ZZ_pX self, long exp)
13
+ cdef ntl_ZZ_pX _powmod(ntl_ZZ_pX self, Integer exp, ntl_ZZ_pX modulus)
14
+
15
+ cdef class ntl_ZZ_pX_Modulus():
16
+ cdef ZZ_pX_Modulus_c x
17
+ cdef ntl_ZZ_pX poly