passagemath-ntl 10.6.36__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.
Files changed (161) hide show
  1. passagemath_ntl-10.6.36.dist-info/METADATA +122 -0
  2. passagemath_ntl-10.6.36.dist-info/RECORD +161 -0
  3. passagemath_ntl-10.6.36.dist-info/WHEEL +6 -0
  4. passagemath_ntl-10.6.36.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-9d41ebf1.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,8 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.lzz_p cimport *
3
+ from sage.libs.ntl.ntl_lzz_pContext cimport ntl_zz_pContext_class
4
+
5
+ cdef class ntl_zz_p():
6
+ cdef zz_p_c x
7
+ cdef ntl_zz_pContext_class c
8
+ cdef ntl_zz_p _new(ntl_zz_p self)
@@ -0,0 +1,440 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: libraries = NTL_LIBRARIES gmp M_LIBRARIES
3
+ # distutils: extra_compile_args = NTL_CFLAGS
4
+ # distutils: include_dirs = NTL_INCDIR
5
+ # distutils: library_dirs = NTL_LIBDIR
6
+ # distutils: extra_link_args = NTL_LIBEXTRA
7
+ # distutils: language = c++
8
+ """
9
+ ntl_lzz_p.pyx
10
+
11
+ Wraps NTL's zz_p type for Sage
12
+
13
+ NOTE: This file is essentially useless. While we provide
14
+ this wrapper for consistency, this should never be used in
15
+ *production* code, i.e. anything intended to be fast. The
16
+ reason for this is simple: this is a wrapper for a Python
17
+ interface to the zz_p type, which is just a long! Any speed
18
+ gains you get from working with longs will be TOTALLY
19
+ destroyed by the overhead of having a wrapper.
20
+
21
+ AUTHORS:
22
+
23
+ - Craig Citro
24
+ """
25
+
26
+ # ****************************************************************************
27
+ # Copyright (C) 2005 William Stein <wstein@gmail.com>
28
+ #
29
+ # This program is free software: you can redistribute it and/or modify
30
+ # it under the terms of the GNU General Public License as published by
31
+ # the Free Software Foundation, either version 2 of the License, or
32
+ # (at your option) any later version.
33
+ # https://www.gnu.org/licenses/
34
+ # ****************************************************************************
35
+
36
+ from cysignals.signals cimport sig_on, sig_off
37
+
38
+ include 'misc.pxi'
39
+ include 'decl.pxi'
40
+ from sage.libs.gmp.mpz cimport *
41
+
42
+ from cpython.object cimport Py_EQ, Py_NE
43
+ from sage.rings.integer import Integer
44
+ from sage.rings.integer_ring import IntegerRing
45
+ from sage.rings.integer cimport Integer
46
+
47
+ from sage.rings.finite_rings.integer_mod cimport IntegerMod_gmp, IntegerMod_int, IntegerMod_int64
48
+
49
+ from sage.libs.ntl.ntl_lzz_pContext import ntl_zz_pContext
50
+ from sage.libs.ntl.ntl_lzz_pContext cimport ntl_zz_pContext_class
51
+ from sage.arith.power cimport generic_power_pos
52
+
53
+ ZZ_sage = IntegerRing()
54
+
55
+ ##############################################################################
56
+ #
57
+ # zz_pX -- polynomials over the integers modulo p, p small
58
+ #
59
+ ##############################################################################
60
+
61
+ cdef class ntl_zz_p():
62
+ r"""
63
+ The class \class{zz_p} implements arithmetic modulo `p`,
64
+ for p smaller than a machine word.
65
+
66
+ NOTE: This type is provided mostly for completeness, and
67
+ shouldn't be used in any production code.
68
+ """
69
+ # See ntl_zz_p.pxd for definition of data members
70
+ def __init__(self, a=0, modulus=None):
71
+ """
72
+ EXAMPLES::
73
+
74
+ sage: f = ntl.zz_p(5,7)
75
+ sage: f
76
+ 5
77
+ sage: g = ntl.zz_p(int(-5),7)
78
+ sage: g
79
+ 2
80
+ """
81
+ if modulus is None:
82
+ raise ValueError("You must specify a modulus.")
83
+
84
+ if isinstance(modulus, Integer):
85
+ p_sage = modulus
86
+ else:
87
+ p_sage = Integer(self.c.p)
88
+
89
+ #self.c.restore_c() ## This was done in __new__
90
+
91
+ if isinstance(a, IntegerMod_int):
92
+ if (self.c.p == (<IntegerMod_int>a)._modulus.int32): ## this is slow
93
+ self.x = (<IntegerMod_int>a).ivalue
94
+ else:
95
+ raise ValueError("Mismatched modulus for converting to zz_p.")
96
+
97
+ elif isinstance(a, IntegerMod_int64):
98
+ if (self.c.p == (<IntegerMod_int64>a)._modulus.int64): ## this is slow
99
+ self.x = (<IntegerMod_int64>a).ivalue
100
+ else:
101
+ raise ValueError("Mismatched modulus for converting to zz_p.")
102
+
103
+ elif isinstance(a, IntegerMod_gmp):
104
+ if (p_sage == (<IntegerMod_gmp>a)._modulus.sageInteger): ## this is slow
105
+ self.x = mpz_get_si((<IntegerMod_gmp>a).value)
106
+ else:
107
+ raise ValueError("Mismatched modulus for converting to zz_p.")
108
+
109
+ elif isinstance(a, Integer):
110
+ self.x = mpz_get_si((<Integer>a).value) % self.c.p
111
+
112
+ elif isinstance(a, int):
113
+ ## we're lucky that python int is no larger than long
114
+ self.x = (<long>a) % self.c.p
115
+ else:
116
+ a = Integer(a)
117
+ self.x = mpz_get_si((<Integer>a).value) % self.c.p
118
+
119
+ return
120
+
121
+ def __cinit__(self, v=None, modulus=None):
122
+ #################### WARNING ###################
123
+ ## Before creating a zz_p, you must create a ##
124
+ ## zz_pContext, and restore it. In Python, ##
125
+ ## the error checking in __init__ will prevent##
126
+ ## you from constructing a zz_p ##
127
+ ## inappropriately. However, from Cython, you##
128
+ ## could do r = ntl_zz_p.__new__(ntl_zz_p) without
129
+ ## first restoring a zz_pContext, which could ##
130
+ ## have unfortunate consequences. See _new ##
131
+ ## defined below for an example of the right ##
132
+ ## way to short-circuit __init__ (or just call##
133
+ ## _new in your own code). ##
134
+ ################################################
135
+ if modulus is None:
136
+ return
137
+ if isinstance(modulus, ntl_zz_pContext_class):
138
+ self.c = <ntl_zz_pContext_class>modulus
139
+ elif isinstance(modulus, Integer):
140
+ self.c = <ntl_zz_pContext_class>ntl_zz_pContext(modulus)
141
+ elif isinstance(modulus, int):
142
+ self.c = <ntl_zz_pContext_class>ntl_zz_pContext(modulus)
143
+ else:
144
+ try:
145
+ modulus = int(modulus)
146
+ except Exception:
147
+ raise ValueError("%s is not a valid modulus." % modulus)
148
+ self.c = <ntl_zz_pContext_class>ntl_zz_pContext(modulus)
149
+
150
+ ## now that we've determined the modulus, set that modulus.
151
+ self.c.restore_c()
152
+
153
+ cdef ntl_zz_p _new(self):
154
+ """
155
+ Quick and dirty zz_p object creation.
156
+
157
+ EXAMPLES::
158
+
159
+ sage: x = ntl.zz_p(23,75)
160
+ sage: y = x*x ## indirect doctest
161
+ """
162
+ cdef ntl_zz_p y
163
+ self.c.restore_c()
164
+ y = ntl_zz_p.__new__(ntl_zz_p)
165
+ y.c = self.c
166
+ return y
167
+
168
+ def __reduce__(self):
169
+ """
170
+ For pickling.
171
+
172
+ TESTS::
173
+
174
+ sage: f = ntl.zz_p(16,244)
175
+ sage: loads(dumps(f)) == f
176
+ True
177
+ """
178
+ return make_zz_p, (zz_p_rep(self.x), self.c)
179
+
180
+ def __repr__(self):
181
+ """
182
+ Return the string representation of ``self``.
183
+
184
+ EXAMPLES::
185
+
186
+ sage: ntl.zz_p(3,79).__repr__()
187
+ '3'
188
+ """
189
+ return repr(Integer(zz_p_rep(self.x)))
190
+
191
+ def __add__(ntl_zz_p self, other):
192
+ """
193
+ EXAMPLES::
194
+
195
+ sage: ntl.zz_p(5,23) + ntl.zz_p(6,23)
196
+ 11
197
+ """
198
+ cdef ntl_zz_p y
199
+ if not isinstance(other, ntl_zz_p):
200
+ other = ntl_zz_p(other, modulus=self.c)
201
+ elif self.c is not (<ntl_zz_p>other).c:
202
+ raise ValueError("arithmetic operands must have the same modulus.")
203
+ self.c.restore_c()
204
+ y = self._new()
205
+ zz_p_add(y.x, self.x, (<ntl_zz_p>other).x)
206
+ return y
207
+
208
+ def __sub__(ntl_zz_p self, other):
209
+ """
210
+ EXAMPLES::
211
+
212
+ sage: ntl.zz_p(5,23) - ntl.zz_p(6,23)
213
+ 22
214
+ """
215
+ cdef ntl_zz_p y
216
+ if not isinstance(other, ntl_zz_p):
217
+ other = ntl_zz_p(other, modulus=self.c)
218
+ elif self.c is not (<ntl_zz_p>other).c:
219
+ raise ValueError("arithmetic operands must have the same modulus.")
220
+ self.c.restore_c()
221
+ y = self._new()
222
+ zz_p_sub(y.x, self.x, (<ntl_zz_p>other).x)
223
+ return y
224
+
225
+ def __mul__(ntl_zz_p self, other):
226
+ """
227
+ EXAMPLES::
228
+
229
+ sage: ntl.zz_p(5,23) * ntl.zz_p(6,23)
230
+ 7
231
+ """
232
+ cdef ntl_zz_p y
233
+ if not isinstance(other, ntl_zz_p):
234
+ other = ntl_zz_p(other, modulus=self.c)
235
+ elif self.c is not (<ntl_zz_p>other).c:
236
+ raise ValueError("arithmetic operands must have the same modulus.")
237
+ y = self._new()
238
+ self.c.restore_c()
239
+ zz_p_mul(y.x, self.x, (<ntl_zz_p>other).x)
240
+ return y
241
+
242
+ def __truediv__(ntl_zz_p self, other):
243
+ """
244
+ EXAMPLES::
245
+
246
+ sage: ntl.zz_p(5,23) / ntl.zz_p(2,23)
247
+ 14
248
+ """
249
+ cdef ntl_zz_p q
250
+ if not isinstance(other, ntl_zz_p):
251
+ other = ntl_zz_p(other, modulus=self.c)
252
+ elif self.c is not (<ntl_zz_p>other).c:
253
+ raise ValueError("arithmetic operands must have the same modulus.")
254
+ q = self._new()
255
+ self.c.restore_c()
256
+ sig_on()
257
+ zz_p_div(q.x, self.x, (<ntl_zz_p>other).x)
258
+ sig_off()
259
+ return q
260
+
261
+ def __pow__(ntl_zz_p self, long n, ignored):
262
+ """
263
+ Return the `n`-th nonnegative power of ``self``.
264
+
265
+ EXAMPLES::
266
+
267
+ sage: g = ntl.zz_p(5, 13)
268
+ sage: g ^ 10
269
+ 12
270
+ sage: g ^ (-1)
271
+ 8
272
+ sage: g ^ (-5)
273
+ 8
274
+ sage: g ^ 0
275
+ 1
276
+ sage: z = ntl.zz_p(0, 13)
277
+ sage: z ^ 0
278
+ 1
279
+ sage: z ^ 1
280
+ 0
281
+ sage: z ^ (-1)
282
+ Traceback (most recent call last):
283
+ ...
284
+ ZeroDivisionError: inverse does not exist
285
+ """
286
+ self.c.restore_c()
287
+ if n == 0:
288
+ return ntl_zz_p(1, self.c)
289
+
290
+ if self.is_zero():
291
+ if n > 0:
292
+ return self
293
+ raise ZeroDivisionError("inverse does not exist")
294
+
295
+ cdef ntl_zz_p y
296
+ if n > 0:
297
+ return generic_power_pos(self, <unsigned long>n)
298
+ else:
299
+ y = ntl_zz_p.__new__(ntl_zz_p)
300
+ y.c = self.c
301
+ zz_p_inv(y.x, self.x)
302
+ return generic_power_pos(y, -<unsigned long>n)
303
+
304
+ def __neg__(self):
305
+ """
306
+ Return the negative of ``self``.
307
+
308
+ EXAMPLES::
309
+
310
+ sage: f = ntl.zz_p(5,234)
311
+ sage: -f ## indirect doctest
312
+ 229
313
+ """
314
+ cdef ntl_zz_p y
315
+ y = self._new()
316
+ self.c.restore_c()
317
+ zz_p_negate(y.x, self.x)
318
+ return y
319
+
320
+ def __richcmp__(ntl_zz_p self, other, int op):
321
+ """
322
+ Compare ``self`` to ``other``.
323
+
324
+ EXAMPLES::
325
+
326
+ sage: f = ntl.zz_p(3,20)
327
+ sage: g = ntl.zz_p(2,20)
328
+ sage: h = ntl.zz_p(3,60)
329
+ sage: f == g
330
+ False
331
+ sage: f == f
332
+ True
333
+ sage: f == h
334
+ True
335
+ sage: f == 3
336
+ True
337
+ """
338
+ self.c.restore_c()
339
+
340
+ if op != Py_EQ and op != Py_NE:
341
+ raise TypeError("integers mod p are not ordered")
342
+
343
+ cdef ntl_zz_p b
344
+ try:
345
+ b = <ntl_zz_p?>other
346
+ except TypeError:
347
+ b = ntl_zz_p(other, self.c)
348
+
349
+ return (op == Py_EQ) == (self.x == b.x)
350
+
351
+ def __int__(self):
352
+ """
353
+ Return ``self`` as an int.
354
+
355
+ EXAMPLES::
356
+
357
+ sage: # needs sage.libs.pari
358
+ sage: ntl.zz_p(3, next_prime(100)).__int__()
359
+ 3
360
+ sage: int(ntl.zz_p(3, next_prime(100)))
361
+ 3
362
+ sage: type(int(ntl.zz_p(3, next_prime(100))))
363
+ <... 'int'>
364
+ """
365
+ return zz_p_rep(self.x)
366
+
367
+ def square(self):
368
+ """
369
+ Return f*f.
370
+
371
+ EXAMPLES::
372
+
373
+ sage: f = ntl.zz_p(15,23)
374
+ sage: f*f
375
+ 18
376
+ """
377
+ cdef ntl_zz_p y
378
+ y = self._new()
379
+ self.c.restore_c()
380
+ zz_p_sqr(y.x, self.x)
381
+ return y
382
+
383
+ def is_zero(self):
384
+ """
385
+ Return ``True`` exactly if this element is 0.
386
+
387
+ EXAMPLES::
388
+
389
+ sage: f = ntl.zz_p(0,20)
390
+ sage: f.is_zero()
391
+ True
392
+ sage: f = ntl.zz_p(1,20)
393
+ sage: f.is_zero()
394
+ False
395
+ """
396
+ self.c.restore_c()
397
+ return zz_p_rep(self.x) == 0
398
+
399
+ def is_one(self):
400
+ """
401
+ Return ``True`` exactly if this element is 1.
402
+
403
+ EXAMPLES::
404
+
405
+ sage: f = ntl.zz_p(1,11)
406
+ sage: f.is_one()
407
+ True
408
+ sage: f = ntl.zz_p(5,11)
409
+ sage: f.is_one()
410
+ False
411
+ """
412
+ self.c.restore_c()
413
+ return zz_p_rep(self.x) == 1
414
+
415
+ def clear(self):
416
+ """
417
+ Reset this element to 0.
418
+
419
+ EXAMPLES::
420
+
421
+ sage: x = ntl.zz_p(5,102) ; x
422
+ 5
423
+ sage: x.clear() ; x
424
+ 0
425
+ """
426
+ self.c.restore_c()
427
+ zz_p_clear(self.x)
428
+
429
+
430
+ def make_zz_p(val, context):
431
+ """
432
+ For unpickling.
433
+
434
+ TESTS::
435
+
436
+ sage: f = ntl.zz_p(1, 12)
437
+ sage: loads(dumps(f)) == f
438
+ True
439
+ """
440
+ return ntl_zz_p(val, context)
@@ -0,0 +1,7 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport zz_pContext_c
3
+
4
+ cdef class ntl_zz_pContext_class():
5
+ cdef zz_pContext_c x
6
+ cdef void restore_c(self) noexcept
7
+ cdef long p
@@ -0,0 +1,137 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: libraries = NTL_LIBRARIES gmp M_LIBRARIES
3
+ # distutils: extra_compile_args = NTL_CFLAGS
4
+ # distutils: include_dirs = NTL_INCDIR
5
+ # distutils: library_dirs = NTL_LIBDIR
6
+ # distutils: extra_link_args = NTL_LIBEXTRA
7
+ # distutils: language = c++
8
+
9
+ #*****************************************************************************
10
+ # Copyright (C) 2005 William Stein <wstein@gmail.com>
11
+ #
12
+ # This program is free software: you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation, either version 2 of the License, or
15
+ # (at your option) any later version.
16
+ # http://www.gnu.org/licenses/
17
+ #*****************************************************************************
18
+
19
+ from sage.libs.gmp.mpz cimport mpz_get_si
20
+ include 'misc.pxi'
21
+ include 'decl.pxi'
22
+
23
+ from sage.rings.integer cimport Integer
24
+
25
+ zz_pContextDict = {}
26
+
27
+ cdef class ntl_zz_pContext_class():
28
+ def __init__(self, long v):
29
+ """
30
+ EXAMPLES::
31
+
32
+ # You can construct contexts manually.
33
+ sage: c = ntl.zz_pContext(11)
34
+ sage: n1 = ntl.zz_p(12,c)
35
+ sage: n1
36
+ 1
37
+
38
+ # or You can construct contexts implicitly.
39
+ sage: n2=ntl.zz_p(12, 7)
40
+ sage: n2
41
+ 5
42
+ sage: ntl.zz_p(2,3)+ntl.zz_p(1,3)
43
+ 0
44
+ sage: n2+n1 # Mismatched moduli: It will go BOOM!
45
+ Traceback (most recent call last):
46
+ ...
47
+ ValueError: arithmetic operands must have the same modulus.
48
+ """
49
+ pass
50
+
51
+ def __cinit__(self, long v):
52
+ if v > NTL_SP_BOUND:
53
+ raise ValueError("Modulus (=%s) is too big" % v)
54
+ elif v < 2:
55
+ # Issue 13940: only moduli greater than one are supported.
56
+ raise ValueError("Modulus (=%s) is too small" % v)
57
+
58
+ self.x = zz_pContext_c(v)
59
+ zz_pContextDict[repr(v)] = self
60
+ self.p = v
61
+
62
+ def __reduce__(self):
63
+ """
64
+ EXAMPLES::
65
+
66
+ sage: c=ntl.zz_pContext(13)
67
+ sage: loads(dumps(c)) is c
68
+ True
69
+ """
70
+ return ntl_zz_pContext, (self.p,)
71
+
72
+ def modulus(self):
73
+ """
74
+ Print the modulus for ``self``.
75
+
76
+ EXAMPLES::
77
+
78
+ sage: c1 = ntl.zz_pContext(36)
79
+ sage: c1.modulus()
80
+ 36
81
+ """
82
+ return self.p
83
+
84
+ def restore(self):
85
+ """
86
+ Restore a zz_pContext.
87
+
88
+ EXAMPLES::
89
+
90
+ sage: c = ntl.zz_pContext(5)
91
+ sage: m = ntl.zz_p(4,7)
92
+ sage: c.restore()
93
+ """
94
+ self.restore_c()
95
+
96
+ cdef void restore_c(self) noexcept:
97
+ """
98
+ Actual code for the above.
99
+
100
+ EXAMPLES::
101
+
102
+ sage: n = ntl.zz_p(3,5)
103
+ sage: m = ntl.zz_p(4,7)
104
+ sage: n*n ## indirect doctest
105
+ 4
106
+ """
107
+ self.x.restore()
108
+
109
+
110
+ def ntl_zz_pContext( v ):
111
+ """
112
+ Creation function for a zz_p context.
113
+
114
+ EXAMPLES::
115
+
116
+ sage: f = ntl.zz_pContext(26)
117
+ sage: f = ntl.zz_pContext(10^100)
118
+ Traceback (most recent call last):
119
+ ...
120
+ ValueError: Modulus (=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) is too big
121
+ sage: f = ntl.zz_pContext(1)
122
+ Traceback (most recent call last):
123
+ ...
124
+ ValueError: Modulus (=1) is too small
125
+ sage: f = ntl.zz_pContext(0)
126
+ Traceback (most recent call last):
127
+ ...
128
+ ValueError: Modulus (=0) is too small
129
+ """
130
+ if v > NTL_SP_BOUND:
131
+ raise ValueError("Modulus (=%s) is too big" % v)
132
+ if isinstance(v, Integer):
133
+ v = mpz_get_si((<Integer>v).value)
134
+ try:
135
+ return zz_pContextDict[repr(v)]
136
+ except KeyError:
137
+ return ntl_zz_pContext_class(v)
@@ -0,0 +1,10 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.lzz_p cimport *
3
+ from sage.libs.ntl.lzz_pX cimport *
4
+
5
+ from sage.libs.ntl.ntl_lzz_pContext cimport ntl_zz_pContext_class
6
+
7
+ cdef class ntl_zz_pX():
8
+ cdef zz_pX_c x
9
+ cdef ntl_zz_pContext_class c
10
+ cdef ntl_zz_pX _new(self)