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
sage/libs/ntl/all.py ADDED
@@ -0,0 +1,72 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ r"""
3
+ Victor Shoup's NTL C++ Library
4
+
5
+ Sage provides an interface to Victor Shoup's C++ library NTL.
6
+ Features of this library include *incredibly fast* arithmetic with
7
+ polynomials and asymptotically fast factorization of polynomials.
8
+ """
9
+ # ****************************************************************************
10
+ # Copyright (C) 2005 William Stein <wstein@gmail.com>
11
+ #
12
+ # Distributed under the terms of the GNU General Public License (GPL)
13
+ #
14
+ # This code is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # General Public License for more details.
18
+ #
19
+ # The full text of the GPL is available at:
20
+ #
21
+ # https://www.gnu.org/licenses/
22
+ # ****************************************************************************
23
+
24
+ from sage.libs.ntl.ntl_ZZ import (
25
+ ntl_setSeed,
26
+ ntl_ZZ as ZZ,
27
+ randomBnd as ZZ_random,
28
+ randomBits as ZZ_random_bits)
29
+
30
+ from sage.libs.ntl.ntl_ZZ_pContext import ntl_ZZ_pContext as ZZ_pContext
31
+
32
+ from sage.libs.ntl.ntl_ZZ_p import (
33
+ ntl_ZZ_p as ZZ_p,
34
+ ntl_ZZ_p_random_element as ZZ_p_random)
35
+
36
+ from sage.libs.ntl.ntl_ZZX import (
37
+ ntl_ZZX as ZZX,
38
+ zero_ZZX, one_ZZX)
39
+
40
+ from sage.libs.ntl.ntl_ZZ_pX import ntl_ZZ_pX as ZZ_pX
41
+
42
+ from sage.libs.ntl.ntl_ZZ_pEContext import ntl_ZZ_pEContext as ZZ_pEContext
43
+
44
+ from sage.libs.ntl.ntl_ZZ_pE import ntl_ZZ_pE as ZZ_pE
45
+
46
+ from sage.libs.ntl.ntl_ZZ_pEX import ntl_ZZ_pEX as ZZ_pEX
47
+
48
+ from sage.libs.ntl.ntl_lzz_pContext import ntl_zz_pContext as zz_pContext
49
+
50
+ from sage.libs.ntl.ntl_lzz_p import ntl_zz_p as zz_p
51
+
52
+ from sage.libs.ntl.ntl_lzz_pX import ntl_zz_pX as zz_pX
53
+
54
+ from sage.libs.ntl.ntl_mat_ZZ import ntl_mat_ZZ as mat_ZZ
55
+
56
+ from sage.libs.ntl.ntl_GF2 import ntl_GF2 as GF2
57
+
58
+ from sage.libs.ntl.ntl_GF2X import (
59
+ ntl_GF2X as GF2X,
60
+ GF2XHexOutput)
61
+
62
+ from sage.libs.ntl.ntl_GF2EContext import ntl_GF2EContext as GF2EContext
63
+
64
+ from sage.libs.ntl.ntl_GF2E import (
65
+ ntl_GF2E as GF2E,
66
+ ntl_GF2E_random as GF2E_random)
67
+
68
+ from sage.libs.ntl.ntl_GF2EX import ntl_GF2EX as GF2EX
69
+
70
+ from sage.libs.ntl.ntl_mat_GF2E import ntl_mat_GF2E as mat_GF2E
71
+
72
+ from sage.libs.ntl.ntl_mat_GF2 import ntl_mat_GF2 as mat_GF2
@@ -0,0 +1,106 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ r"""
3
+ Inline conversions between NTL and Sage
4
+
5
+ Each NTL type has a corresponding Sage types and we use the following
6
+ conventions for conversion functions
7
+
8
+ - ``new_ntl_XXX`` : create a new ntl object
9
+ - ``new_sage_XXX`` : create a new Sage object
10
+ - ``set_ntl_XXX`` : set the entries of the ntl object
11
+ - ``set_sage_XXX`` : set the entries of the Sage object
12
+ """
13
+ #*****************************************************************************
14
+ # Copyright (C) 2007 Martin Albrecht
15
+ # Copyright (C) 2008 Clement Pernet
16
+ # Copyright (C) 2018 Vincent Delecroix
17
+ # Copyright (C) 2018 Alex J. Best
18
+ #
19
+ # This program is free software: you can redistribute it and/or modify
20
+ # it under the terms of the GNU General Public License as published by
21
+ # the Free Software Foundation, either version 2 of the License, or
22
+ # (at your option) any later version.
23
+ # http://www.gnu.org/licenses/
24
+ #*****************************************************************************
25
+
26
+ from sage.libs.ntl.types cimport mat_ZZ_p_c
27
+ from sage.libs.ntl.ntl_ZZ_pContext cimport ntl_ZZ_pContext_class
28
+ from sage.libs.ntl.ntl_ZZ_p cimport ntl_ZZ_p
29
+
30
+ from sage.matrix.matrix_modn_dense_float cimport Matrix_modn_dense_float
31
+ from sage.matrix.matrix_modn_dense_double cimport Matrix_modn_dense_double
32
+ from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense
33
+
34
+
35
+ ################################################
36
+ # matrix_modn_dense_float (dense matrix over Z/nZ) #
37
+ ################################################
38
+
39
+ cdef inline void set_ntl_matrix_modn_dense_float(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_float m) noexcept:
40
+ r"""
41
+ set the entries of a NTL matrix from a Sage matrix.
42
+
43
+ INPUT:
44
+
45
+ - ``A`` -- NTL matrix
46
+ - ``m`` -- Sage matrix
47
+ """
48
+ cdef size_t i, j
49
+ cdef ntl_ZZ_p tmp
50
+ A.SetDims(m._nrows, m._ncols)
51
+ for i in range(m._nrows):
52
+ for j in range(m._ncols):
53
+ tmp = ntl_ZZ_p(m[i,j], c)
54
+ A.put(i, j, tmp.x)
55
+
56
+ cdef inline void set_ntl_matrix_modn_dense_double(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_modn_dense_double m) noexcept:
57
+ r"""
58
+ set the entries of a NTL matrix from a Sage matrix.
59
+
60
+ INPUT:
61
+
62
+ - ``A`` -- NTL matrix
63
+ - ``m`` -- Sage matrix
64
+ """
65
+ cdef size_t i, j
66
+ cdef ntl_ZZ_p tmp
67
+ A.SetDims(m._nrows, m._ncols)
68
+ for i in range(m._nrows):
69
+ for j in range(m._ncols):
70
+ tmp = ntl_ZZ_p(m[i,j], c)
71
+ A.put(i, j, tmp.x)
72
+
73
+ cdef inline void set_ntl_matrix_modn_generic_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, Matrix_generic_dense m) noexcept:
74
+ r"""
75
+ set the entries of a NTL matrix from a Sage matrix.
76
+
77
+ INPUT:
78
+
79
+ - ``A`` -- NTL matrix
80
+ - ``m`` -- Sage matrix
81
+ """
82
+ cdef size_t i, j
83
+ cdef ntl_ZZ_p tmp
84
+ A.SetDims(m._nrows, m._ncols)
85
+ for i in range(m._nrows):
86
+ for j in range(m._ncols):
87
+ tmp = ntl_ZZ_p(m[i,j], c)
88
+ A.put(i, j, tmp.x)
89
+
90
+ cdef inline void set_ntl_matrix_modn_dense(mat_ZZ_p_c& A, ntl_ZZ_pContext_class c, m) noexcept:
91
+ r"""
92
+ set the entries of a NTL matrix from a Sage matrix.
93
+
94
+ INPUT:
95
+
96
+ - ``A`` -- NTL matrix
97
+ - ``m`` -- Sage matrix
98
+ """
99
+ if isinstance(m, Matrix_modn_dense_float):
100
+ set_ntl_matrix_modn_dense_float(A, c, m)
101
+ elif isinstance(m, Matrix_modn_dense_double):
102
+ set_ntl_matrix_modn_dense_double(A, c, m)
103
+ elif isinstance(m, Matrix_generic_dense):
104
+ set_ntl_matrix_modn_generic_dense(A, c, m)
105
+ else:
106
+ raise NotImplementedError("Matrix type not yet implemented")
@@ -0,0 +1,7 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport ZZ_c
3
+ from sage.libs.gmp.types cimport mpz_t, mpz_srcptr
4
+
5
+ cdef void ZZ_to_mpz(mpz_t output, ZZ_c* x) noexcept
6
+ cdef void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x) noexcept
7
+ cdef void PyLong_to_ZZ(ZZ_c* z, value) noexcept
@@ -0,0 +1,38 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: depends = NTL/ZZ.h
3
+ # distutils: libraries = NTL_LIBRARIES gmp
4
+ # distutils: extra_compile_args = NTL_CFLAGS
5
+ # distutils: include_dirs = NTL_INCDIR
6
+ # distutils: library_dirs = NTL_LIBDIR
7
+ # distutils: extra_link_args = NTL_LIBEXTRA
8
+ # distutils: language = c++
9
+ """
10
+ Conversion between NTL's ``ZZ`` and various other types
11
+ """
12
+
13
+ #*****************************************************************************
14
+ # Copyright (C) 2015 Jeroen Demeyer <jdemeyer@cage.ugent.be>
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 sage.libs.gmp.mpz cimport mpz_init, mpz_clear
24
+ from sage.libs.gmp.pylong cimport mpz_set_pylong
25
+
26
+ cdef extern from "ntlwrap_impl.h":
27
+ void ZZ_to_mpz(mpz_t output, ZZ_c* x)
28
+ void mpz_to_ZZ(ZZ_c *output, mpz_srcptr x)
29
+
30
+ cdef void PyLong_to_ZZ(ZZ_c* z, value) noexcept:
31
+ """
32
+ Convert ``value`` (which must be a Python ``long``) to NTL.
33
+ """
34
+ cdef mpz_t t
35
+ mpz_init(t)
36
+ mpz_set_pylong(t, value)
37
+ mpz_to_ZZ(z, t)
38
+ mpz_clear(t)
sage/libs/ntl/decl.pxi ADDED
@@ -0,0 +1,18 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport *
3
+ from sage.libs.ntl.ZZ cimport *
4
+ from sage.libs.ntl.ZZ_pX cimport *
5
+ from sage.libs.ntl.ZZ_p cimport *
6
+ from sage.libs.ntl.ZZX cimport *
7
+ from sage.libs.ntl.ZZ_pE cimport *
8
+ from sage.libs.ntl.ZZ_pEX cimport *
9
+ from sage.libs.ntl.GF2 cimport *
10
+ from sage.libs.ntl.GF2X cimport *
11
+ from sage.libs.ntl.GF2E cimport *
12
+ from sage.libs.ntl.GF2EX cimport *
13
+ from sage.libs.ntl.vec_GF2 cimport *
14
+ from sage.libs.ntl.vec_GF2E cimport *
15
+ from sage.libs.ntl.mat_ZZ cimport *
16
+ from sage.libs.ntl.mat_GF2 cimport *
17
+ from sage.libs.ntl.mat_GF2E cimport *
18
+ from sage.libs.ntl.convert cimport mpz_to_ZZ, ZZ_to_mpz
@@ -0,0 +1,63 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: libraries = ntl gmp
3
+ # distutils: extra_compile_args = NTL_CFLAGS
4
+ # distutils: include_dirs = NTL_INCDIR
5
+ # distutils: libraries = NTL_LIBRARIES
6
+ # distutils: library_dirs = NTL_LIBDIR
7
+ # distutils: extra_link_args = NTL_LIBEXTRA
8
+ # distutils: language = c++
9
+ """
10
+ NTL error handler
11
+
12
+ AUTHOR:
13
+
14
+ - Jeroen Demeyer (2015-02-15): initial version, see :issue:`17784`
15
+
16
+ - Jeroen Demeyer (2015-07-09): use standard NTL ``ErrorMsgCallback``,
17
+ see :issue:`18875`
18
+ """
19
+
20
+ #*****************************************************************************
21
+ # Copyright (C) 2015 Jeroen Demeyer <jdemeyer@cage.ugent.be>
22
+ #
23
+ # This program is free software: you can redistribute it and/or modify
24
+ # it under the terms of the GNU General Public License as published by
25
+ # the Free Software Foundation, either version 2 of the License, or
26
+ # (at your option) any later version.
27
+ # http://www.gnu.org/licenses/
28
+ #*****************************************************************************
29
+
30
+
31
+ from sage.libs.ntl.ntl_tools cimport ErrorMsgCallback
32
+ from sage.cpython.string cimport char_to_str
33
+
34
+
35
+ class NTLError(RuntimeError):
36
+ """
37
+ Exceptions from the NTL library.
38
+
39
+ EXAMPLES::
40
+
41
+ sage: a = ntl.ZZX([0])
42
+ sage: a.quo_rem(a)
43
+ Traceback (most recent call last):
44
+ ...
45
+ NTLError: DivRem: division by zero
46
+ """
47
+
48
+
49
+ cdef void NTL_error_callback(const char* s) except *:
50
+ raise NTLError(char_to_str(s))
51
+
52
+
53
+ def setup_NTL_error_callback():
54
+ """
55
+ Setup the NTL error handler callback.
56
+
57
+ EXAMPLES::
58
+
59
+ sage: from sage.libs.ntl.error import setup_NTL_error_callback
60
+ sage: setup_NTL_error_callback()
61
+ """
62
+ global ErrorMsgCallback
63
+ ErrorMsgCallback = NTL_error_callback
@@ -0,0 +1,20 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: depends = NTL/ZZ.h
3
+
4
+ from sage.libs.ntl.types cimport zz_p_c
5
+
6
+ cdef extern from "ntlwrap.h":
7
+ long zz_p_rep "rep"(zz_p_c x)
8
+ long zz_p_isZero "IsZero"(zz_p_c x)
9
+ void zz_p_add "add"(zz_p_c x, zz_p_c a, zz_p_c b)
10
+ void zz_p_sub "sub"(zz_p_c x, zz_p_c a, zz_p_c b)
11
+ void zz_p_negate "NTL::negate"(zz_p_c x, zz_p_c a)
12
+ void zz_p_mul "mul"(zz_p_c x, zz_p_c a, zz_p_c b)
13
+ void zz_p_div "div"(zz_p_c x, zz_p_c a, zz_p_c b)
14
+ void zz_p_inv "inv"(zz_p_c x, zz_p_c a)
15
+ void zz_p_power "NTL::power"(zz_p_c x, zz_p_c a, long e)
16
+ void zz_p_sqr "sqr"(zz_p_c x, zz_p_c a)
17
+ void zz_p_clear "clear"(zz_p_c x)
18
+ void zz_p_set_zero "clear"(zz_p_c x)
19
+ void zz_p_set_one "set"(zz_p_c x)
20
+ void zz_p_swap "swap"(zz_p_c x, zz_p_c y)
@@ -0,0 +1,59 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: depends = NTL/ZZ.h
3
+
4
+ from sage.libs.ntl.types cimport ZZ_c, zz_p_c, zz_pX_c, zz_pX_Modulus_c
5
+
6
+
7
+ cdef extern from "ntlwrap.h":
8
+ char* zz_pX_repr(zz_pX_c* x)
9
+ void zz_pX_SetCoeff_long "SetCoeff"(zz_pX_c x, long i, long a)
10
+ zz_p_c zz_pX_GetCoeff "coeff"(zz_pX_c x, long i)
11
+ void zz_pX_add "add"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
12
+ void zz_pX_sub "sub"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
13
+ void zz_pX_mul "mul"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
14
+ void zz_pX_rmul "mul"(zz_pX_c x, zz_pX_c a, long b)
15
+ void zz_pX_lmul "mul"(zz_pX_c x, long a, zz_pX_c b)
16
+ long zz_pX_div "div"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
17
+ long zz_pX_divide "divide"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
18
+ void zz_pX_mod "rem"(zz_pX_c x, zz_pX_c a, zz_pX_c b)
19
+ void zz_pX_divrem "DivRem"(zz_pX_c q, zz_pX_c r, zz_pX_c a, zz_pX_c b)
20
+ void zz_pX_LeftShift "LeftShift"(zz_pX_c x, zz_pX_c a, long b)
21
+ void zz_pX_RightShift "RightShift"(zz_pX_c x, zz_pX_c a, long b)
22
+ void zz_pX_negate "NTL::negate"(zz_pX_c x, zz_pX_c a)
23
+ zz_p_c zz_pX_LeadCoeff "LeadCoeff"(zz_pX_c x)
24
+ zz_p_c zz_pX_ConstTerm "ConstTerm" (zz_pX_c x)
25
+ void zz_pX_negate "NTL::negate"(zz_pX_c x, zz_pX_c a)
26
+ void zz_pX_trunc "trunc"(zz_pX_c x, zz_pX_c a, long n) ## x = a % X^n
27
+ void zz_pX_MulTrunc "MulTrunc"(zz_pX_c x, zz_pX_c a, zz_pX_c b, long n)
28
+ void zz_pX_SqrTrunc "SqrTrunc"(zz_pX_c x, zz_pX_c a, long n)
29
+ void zz_pX_InvTrunc "InvTrunc"(zz_pX_c x, zz_pX_c a, long n)
30
+ void zz_pX_sqr "sqr"(zz_pX_c x, zz_pX_c a)
31
+ void zz_pX_power "NTL::power"(zz_pX_c x, zz_pX_c a, long e)
32
+ void zz_pX_clear "clear"(zz_pX_c x)
33
+ void zz_pX_SetX "SetX"(zz_pX_c x)
34
+ bint zz_pX_IsX "IsX"(zz_pX_c x)
35
+ bint zz_pX_IsZero "IsZero"(zz_pX_c x)
36
+ bint zz_pX_IsOne "IsOne"(zz_pX_c x)
37
+ long zz_pX_deg "deg"(zz_pX_c x)
38
+ zz_pX_c zz_pX_zero "zz_pX::zero"()
39
+ void zz_pX_diff "diff"(zz_pX_c x, zz_pX_c a)
40
+ void zz_pX_reverse "reverse"(zz_pX_c x, zz_pX_c a)
41
+ void zz_pX_reverse_hi "reverse"(zz_pX_c x, zz_pX_c a, long hi)
42
+ void zz_pX_eval "eval" (zz_p_c fa, zz_pX_c f, zz_p_c a)
43
+ void zz_pX_MakeMonic "MakeMonic"(zz_pX_c x)
44
+
45
+ void zz_pX_Modulus_build "build"(zz_pX_Modulus_c F, zz_pX_c f) # MUST be called before using the modulus
46
+ long zz_pX_Modulus_deg "deg"(zz_pX_Modulus_c F)
47
+
48
+ void zz_pX_MulMod_pre "MulMod"(zz_pX_c x, zz_pX_c a, zz_pX_c b, zz_pX_Modulus_c F)
49
+ void zz_pX_SqrMod_pre "SqrMod"(zz_pX_c x, zz_pX_c a, zz_pX_Modulus_c F)
50
+ void zz_pX_PowerMod_pre "PowerMod"(zz_pX_c x, zz_pX_c a, ZZ_c e, zz_pX_Modulus_c F)
51
+ void zz_pX_PowerMod_long_pre "PowerMod"(zz_pX_c x, zz_pX_c a, long e, zz_pX_Modulus_c F)
52
+ void zz_pX_PowerXMod_pre "PowerXMod"(zz_pX_c x, ZZ_c e, zz_pX_Modulus_c F)
53
+ void zz_pX_PowerXMod_long_pre "PowerXMod"(zz_pX_c x, long e, zz_pX_Modulus_c F)
54
+ void zz_pX_PowerXPlusAMod_pre "PowerXPlusAMod"(zz_pX_c x, zz_p_c a, ZZ_c e, zz_pX_Modulus_c F)
55
+ void zz_pX_PowerXPlusAMod_long_pre "PowerXPlusAMod"(zz_pX_c x, zz_p_c a, long e, zz_pX_Modulus_c F)
56
+ void zz_pX_rem_pre "rem"(zz_pX_c x, zz_pX_c a, zz_pX_Modulus_c F)
57
+ void zz_pX_DivRem_pre "DivRem"(zz_pX_c q, zz_pX_c r, zz_pX_c a, zz_pX_Modulus_c F)
58
+ void zz_pX_div_pre "div"(zz_pX_c q, zz_pX_c a, zz_pX_Modulus_c F)
59
+ void zz_pX_InvMod_pre "InvMod"(zz_pX_c x, zz_pX_c a, zz_pX_Modulus_c F)
@@ -0,0 +1,30 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport mat_GF2_c, vec_GF2_c, GF2_c
3
+
4
+
5
+ cdef extern from "ntlwrap.h":
6
+ void mat_GF2_add "add"( mat_GF2_c x, mat_GF2_c a, mat_GF2_c b)
7
+ void mat_GF2_sub "sub"( mat_GF2_c x, mat_GF2_c a, mat_GF2_c b)
8
+ void mat_GF2_mul "mul"( mat_GF2_c x, mat_GF2_c a, mat_GF2_c b)
9
+ void mat_GF2_negate "NTL::negate"(mat_GF2_c x, mat_GF2_c a)
10
+ void mat_GF2_power "NTL::power"(mat_GF2_c t, mat_GF2_c x, long e)
11
+ GF2_c mat_GF2_determinant "determinant"(mat_GF2_c m)
12
+ void mat_GF2_transpose "transpose"(mat_GF2_c r, mat_GF2_c m)
13
+ long mat_GF2_IsZero "IsZero"(mat_GF2_c x)
14
+
15
+ long mat_GF2_gauss "gauss"(mat_GF2_c A, long w)
16
+ void mat_GF2_solve "solve"(GF2_c d, vec_GF2_c X, mat_GF2_c A, vec_GF2_c b)
17
+ void mat_GF2_inv "inv" (mat_GF2_c X, mat_GF2_c A)
18
+
19
+ long mat_GF2_IsIdent "IsIdent"(mat_GF2_c A, long n)
20
+ long mat_GF2_IsDiag "IsDiag"(mat_GF2_c A, long n, GF2_c d)
21
+
22
+ void mat_GF2_image "image"(mat_GF2_c X, mat_GF2_c A)
23
+ void mat_GF2_kernel "kernel" (mat_GF2_c X, mat_GF2_c A)
24
+
25
+ void vec_GF2_conv_mat_GF2 "conv" (vec_GF2_c out, mat_GF2_c inp)
26
+ void mat_GF2_conv_vec_GF2(mat_GF2_c out, vec_GF2_c inp)
27
+
28
+
29
+ cdef extern from "ntlwrap_impl.h":
30
+ void mat_GF2_setitem(mat_GF2_c* x, int i, int j, GF2_c* z)
@@ -0,0 +1,30 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport mat_GF2E_c, vec_GF2E_c, GF2E_c
3
+
4
+
5
+ cdef extern from "ntlwrap.h":
6
+ void mat_GF2E_add "add"( mat_GF2E_c x, mat_GF2E_c a, mat_GF2E_c b)
7
+ void mat_GF2E_sub "sub"( mat_GF2E_c x, mat_GF2E_c a, mat_GF2E_c b)
8
+ void mat_GF2E_mul "mul"( mat_GF2E_c x, mat_GF2E_c a, mat_GF2E_c b)
9
+ void mat_GF2E_negate "NTL::negate"(mat_GF2E_c x, mat_GF2E_c a)
10
+ void mat_GF2E_power "NTL::power"(mat_GF2E_c t, mat_GF2E_c x, long e)
11
+ GF2E_c mat_GF2E_determinant "determinant"(mat_GF2E_c m)
12
+ void mat_GF2E_transpose "transpose"(mat_GF2E_c r, mat_GF2E_c m)
13
+ long mat_GF2E_IsZero "IsZero"(mat_GF2E_c x)
14
+
15
+ long mat_GF2E_gauss "gauss"(mat_GF2E_c A, long w)
16
+ void mat_GF2E_solve "solve"(GF2E_c d, vec_GF2E_c X, mat_GF2E_c A, vec_GF2E_c b)
17
+ void mat_GF2E_inv "inv" (mat_GF2E_c X, mat_GF2E_c A)
18
+
19
+ long mat_GF2E_IsIdent "IsIdent"(mat_GF2E_c A, long n)
20
+ long mat_GF2E_IsDiag "IsDiag"(mat_GF2E_c A, long n, GF2E_c d)
21
+
22
+ void mat_GF2E_image "image"(mat_GF2E_c X, mat_GF2E_c A)
23
+ void mat_GF2E_kernel "kernel" (mat_GF2E_c X, mat_GF2E_c A)
24
+
25
+ void vec_GF2E_conv_mat_GF2E "conv" (vec_GF2E_c out, mat_GF2E_c inp)
26
+ void mat_GF2E_conv_vec_GF2E(mat_GF2E_c out, vec_GF2E_c inp)
27
+
28
+
29
+ cdef extern from "ntlwrap_impl.h":
30
+ void mat_GF2E_setitem(mat_GF2E_c* x, int i, int j, GF2E_c* z)
@@ -0,0 +1,59 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport mat_ZZ_c, ZZ_c, ZZX_c
3
+
4
+
5
+ cdef extern from "ntlwrap.h":
6
+ void mat_ZZ_mul "mul"( mat_ZZ_c x, mat_ZZ_c a, mat_ZZ_c b)
7
+ void mat_ZZ_add "add"( mat_ZZ_c x, mat_ZZ_c a, mat_ZZ_c b)
8
+ void mat_ZZ_sub "sub"( mat_ZZ_c x, mat_ZZ_c a, mat_ZZ_c b)
9
+ void mat_ZZ_power "NTL::power"( mat_ZZ_c x, mat_ZZ_c a, long e)
10
+ void mat_ZZ_CharPoly "CharPoly"(ZZX_c r, mat_ZZ_c m)
11
+
12
+ cdef long mat_ZZ_LLL_FP "LLL_FP"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
13
+ cdef long mat_ZZ_LLL_FP_U "LLL_FP"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
14
+ cdef long mat_ZZ_LLL_QP "LLL_QP"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
15
+ cdef long mat_ZZ_LLL_QP_U "LLL_QP"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
16
+ cdef long mat_ZZ_LLL_XD "LLL_XD"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
17
+ cdef long mat_ZZ_LLL_XD_U "LLL_XD"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
18
+ cdef long mat_ZZ_LLL_RR "LLL_RR"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
19
+ cdef long mat_ZZ_LLL_RR_U "LLL_RR"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
20
+
21
+ cdef long mat_ZZ_G_LLL_FP "G_LLL_FP"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
22
+ cdef long mat_ZZ_G_LLL_FP_U "G_LLL_FP"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
23
+ cdef long mat_ZZ_G_LLL_QP "G_LLL_QP"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
24
+ cdef long mat_ZZ_G_LLL_QP_U "G_LLL_QP"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
25
+ cdef long mat_ZZ_G_LLL_XD "G_LLL_XD"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
26
+ cdef long mat_ZZ_G_LLL_XD_U "G_LLL_XD"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
27
+ cdef long mat_ZZ_G_LLL_RR "G_LLL_RR"(mat_ZZ_c B, double delta, int deep, int check , int verbose)
28
+ cdef long mat_ZZ_G_LLL_RR_U "G_LLL_RR"(mat_ZZ_c B, mat_ZZ_c U, double delta, int deep, int check , int verbose)
29
+
30
+ cdef long mat_ZZ_BKZ_FP "BKZ_FP"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
31
+ cdef long mat_ZZ_BKZ_FP_U "BKZ_FP"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
32
+ cdef long mat_ZZ_BKZ_XD "BKZ_XD"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
33
+ cdef long mat_ZZ_BKZ_XD_U "BKZ_XD"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
34
+ cdef long mat_ZZ_BKZ_QP "BKZ_QP"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
35
+ cdef long mat_ZZ_BKZ_QP_U "BKZ_QP"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
36
+ cdef long mat_ZZ_BKZ_QP1 "BKZ_QP1"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
37
+ cdef long mat_ZZ_BKZ_QP1_U "BKZ_QP1"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
38
+ cdef long mat_ZZ_BKZ_RR "BKZ_RR"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
39
+ cdef long mat_ZZ_BKZ_RR_U "BKZ_RR"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
40
+
41
+ cdef long mat_ZZ_G_BKZ_FP "G_BKZ_FP"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
42
+ cdef long mat_ZZ_G_BKZ_FP_U "G_BKZ_FP"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
43
+ cdef long mat_ZZ_G_BKZ_XD "G_BKZ_XD"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
44
+ cdef long mat_ZZ_G_BKZ_XD_U "G_BKZ_XD"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
45
+ cdef long mat_ZZ_G_BKZ_QP "G_BKZ_QP"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
46
+ cdef long mat_ZZ_G_BKZ_QP_U "G_BKZ_QP"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
47
+ cdef long mat_ZZ_G_BKZ_QP1 "G_BKZ_QP1"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
48
+ cdef long mat_ZZ_G_BKZ_QP1_U "G_BKZ_QP1"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
49
+ cdef long mat_ZZ_G_BKZ_RR "G_BKZ_RR"(mat_ZZ_c B, double delta, long BlockSize, long prune, int check, long verbose)
50
+ cdef long mat_ZZ_G_BKZ_RR_U "G_BKZ_RR"(mat_ZZ_c B, mat_ZZ_c U, double delta, long BlockSize, long prune, int check, long verbose)
51
+
52
+
53
+ cdef extern from "ntlwrap_impl.h":
54
+ void mat_ZZ_setitem(mat_ZZ_c* x, int i, int j, ZZ_c* z)
55
+ ZZ_c* mat_ZZ_getitem(mat_ZZ_c* x, int i, int j)
56
+ ZZ_c* mat_ZZ_determinant(mat_ZZ_c* x, long deterministic)
57
+ mat_ZZ_c* mat_ZZ_HNF(mat_ZZ_c* A, ZZ_c* D)
58
+ cdef long mat_ZZ_LLL(ZZ_c **det, mat_ZZ_c *x, long a, long b, long verbose)
59
+ cdef long mat_ZZ_LLL_U(ZZ_c **det, mat_ZZ_c *x, mat_ZZ_c *U, long a, long b, long verbose)
sage/libs/ntl/misc.pxi ADDED
@@ -0,0 +1,33 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ # distutils: depends = NTL/ZZ.h
3
+
4
+ from cysignals.memory cimport sig_free
5
+ from cysignals.signals cimport sig_off
6
+
7
+ # Unset the signal handler and create a string from the buffer,
8
+ # then free the memory in the buffer.
9
+ cdef extern from *:
10
+ void del_charstar "delete[]"(char*)
11
+
12
+ cdef object string(char* s):
13
+ """
14
+ Take a char* allocated using malloc, and converts it to a Python
15
+ string, then deletes the allocated memory. Also unsets the signal
16
+ handler, so you *must* call sig_on() right before calling this!
17
+ """
18
+ sig_off()
19
+ # Makes a python string and deletes what is pointed to by s.
20
+ t = str(s)
21
+ sig_free(s)
22
+ return t
23
+
24
+ cdef object string_delete(char* s):
25
+ """
26
+ Take a char* allocated using C++ new, and converts it to a Python
27
+ string, then deletes the allocated memory. Also unsets the signal
28
+ handler, so you *must* call sig_on() right before calling this!
29
+ """
30
+ sig_off()
31
+ t = str(s)
32
+ del_charstar(s)
33
+ return t
@@ -0,0 +1,5 @@
1
+ # sage_setup: distribution = sagemath-ntl
2
+ from sage.libs.ntl.types cimport GF2_c
3
+
4
+ cdef class ntl_GF2():
5
+ cdef GF2_c x