source: sage/libs/ntl/ntl_GF2EX.pyx @ 6418:9d4fe59df7c2

Revision 6418:9d4fe59df7c2, 2.8 KB checked in by Joel B. Mohler <jbm5@…>, 6 years ago (diff)

NTL rewrite to split up files and embed structures in cython objects

sage/libs/ntl/decl.pxi HG: changed sage/libs/ntl/init.pxi HG: changed sage/libs/ntl/ntl_GF2E.pxd HG: changed sage/libs/ntl/ntl_GF2E.pyx HG: changed
sage/libs/ntl/ntl_GF2EX.pxd HG: changed sage/libs/ntl/ntl_GF2EX.pyx HG: changed sage/libs/ntl/ntl_GF2X.pxd HG: changed sage/libs/ntl/ntl_GF2X.pyx
sage/libs/ntl/ntl_ZZX.pyx HG: changed sage/libs/ntl/ntl_ZZ_p.pxd HG: changed sage/libs/ntl/ntl_ZZ_p.pyx HG: changed
sage/libs/ntl/ntl_ZZ_pContext.pxd HG: changed sage/libs/ntl/ntl_ZZ_pContext.pyx HG: changed sage/libs/ntl/ntl_ZZ_pX.pxd HG: changed
sage/libs/ntl/ntl_ZZ_pX.pyx HG: changed sage/libs/ntl/ntl_mat_GF2E.pxd HG: changed sage/libs/ntl/ntl_mat_GF2E.pyx HG: changed
sage/libs/ntl/ntl_mat_ZZ.pxd HG: changed sage/libs/ntl/ntl_mat_ZZ.pyx HG: changed sage/rings/bernoulli_mod_p.pyx HG: changed
sage/rings/number_field/number_field_element.pyx HG: changed sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py HG: changed
sage/rings/polynomial/polynomial_element_generic.py HG: changed sage/rings/polynomial/polynomial_ring.py HG: changed
sage/schemes/hyperelliptic_curves/frobenius.pyx HG: changed sage/structure/coerce.pyx HG: changed setup.py HG: removed sage/libs/ntl/ntl.pxd HG:
removed sage/libs/ntl/ntl.pyx

Line 
1#*****************************************************************************
2#       Copyright (C) 2005 William Stein <wstein@gmail.com>
3#
4#  Distributed under the terms of the GNU General Public License (GPL)
5#
6#    This code is distributed in the hope that it will be useful,
7#    but WITHOUT ANY WARRANTY; without even the implied warranty of
8#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9#    General Public License for more details.
10#
11#  The full text of the GPL is available at:
12#
13#                  http://www.gnu.org/licenses/
14#*****************************************************************************
15
16include "../../ext/interrupt.pxi"
17include "../../ext/stdsage.pxi"
18include 'misc.pxi'
19include 'decl.pxi'
20
21##############################################################################
22#
23# ntl_GF2EX: Polynomials over GF(2) via NTL
24#
25# AUTHORS:
26#  - Martin Albrecht <malb@informatik.uni-bremen.de> 2006-01: initial version
27#
28##############################################################################
29
30cdef class ntl_GF2EX:
31    r"""
32    """
33    def __init__(self, x=[]):
34        """
35        EXAMPLES:
36            sage: ntl.set_modulus(ntl.ZZ(3))
37            sage: m=ntl.GF2E_modulus(ntl.GF2X([1,1,0,1,1,0,0,0,1]))
38            sage: ntl.GF2EX('[[1 0] [2 1]]')
39            [[1] [0 1]]
40        """
41        s = str(x)
42        _sig_on
43        GF2EX_from_str(&self.x, s)
44        _sig_off
45
46    def __new__(self, x=[]):
47        GF2EX_construct(&self.x)
48
49    def __dealloc__(self):
50        GF2EX_destruct(&self.x)
51
52    def __reduce__(self):
53        raise NotImplementedError
54
55    def __repr__(self):
56        _sig_on
57        return string_delete(GF2EX_to_str(&self.x))
58
59    def __mul__(ntl_GF2EX self, other):
60        cdef ntl_GF2EX y
61        cdef ntl_GF2EX r = ntl_GF2EX()
62        if not isinstance(other, ntl_GF2EX):
63            other = ntl_GF2EX(other)
64        y = other
65        _sig_on
66        GF2EX_mul(r.x, self.x, y.x)
67        _sig_off
68        return r
69
70    def __sub__(ntl_GF2EX self, other):
71        cdef ntl_GF2EX y
72        cdef ntl_GF2EX r = ntl_GF2EX()
73        if not isinstance(other, ntl_GF2EX):
74            other = ntl_GF2EX(other)
75        y = other
76        _sig_on
77        GF2EX_sub(r.x, self.x, y.x)
78        _sig_off
79        return r
80
81    def __add__(ntl_GF2EX self, other):
82        cdef ntl_GF2EX y
83        cdef ntl_GF2EX r = ntl_GF2EX()
84        if not isinstance(other, ntl_GF2EX):
85            other = ntl_GF2EX(other)
86        y = other
87        _sig_on
88        GF2EX_add(r.x, self.x, y.x)
89        _sig_off
90        return r
91
92    def __neg__(ntl_GF2EX self):
93        cdef ntl_GF2EX r = ntl_GF2EX()
94        _sig_on
95        GF2EX_negate(r.x, self.x)
96        _sig_off
97        return r
98
99    def __pow__(ntl_GF2EX self, long e, ignored):
100        cdef ntl_GF2EX r = ntl_GF2EX()
101        _sig_on
102        GF2EX_power(r.x, self.x, e)
103        _sig_off
104        return r
Note: See TracBrowser for help on using the repository browser.