Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#***************************************************************************** # Copyright (C) 2005 William Stein <wstein@gmail.com> # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import absolute_import
from cysignals.signals cimport sig_on, sig_off from sage.ext.cplusplus cimport ccrepr, ccreadstr
include 'misc.pxi' include 'decl.pxi'
from cpython.object cimport Py_EQ, Py_NE from .ntl_ZZ import unpickle_class_args from .ntl_GF2EContext import ntl_GF2EContext from .ntl_GF2EContext cimport ntl_GF2EContext_class from .ntl_GF2E cimport ntl_GF2E
############################################################################## # # ntl_GF2EX: Polynomials over GF(2) via NTL # # AUTHORS: # - Martin Albrecht <malb@informatik.uni-bremen.de> 2006-01: initial version # ##############################################################################
cdef class ntl_GF2EX(object): r""" Minimal wrapper of NTL's GF2EX class. """ def __init__(self, modulus=None, x=[]): """ Minimal wrapper of NTL's GF2EX class.
EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: ntl.GF2EX(ctx, '[[1 0] [2 1]]') [[1] [0 1]] """ raise ValueError("You must specify a modulus when creating a GF2E.")
def __cinit__(self, modulus=None, x=[]): #################### WARNING ################### ## Before creating a GF2E, you must create a ## ## GF2EContext, and restore it. In Python, ## ## the error checking in __init__ will prevent## ## you from constructing an ntl_GF2E ## ## inappropriately. However, from Cython, you## ## could do r = ntl_GF2E.__new__(ntl_GF2E) without ## first restoring a GF2EContext, which could ## ## have unfortunate consequences. See _new ## ## defined below for an example of the right ## ## way to short-circuit __init__ (or just call## ## _new in your own code). ## ################################################ else: self.c = <ntl_GF2EContext_class>ntl_GF2EContext(modulus) self.c.restore_c()
cdef ntl_GF2E _new_element(self): cdef ntl_GF2E r self.c.restore_c() r = ntl_GF2E.__new__(ntl_GF2E) r.c = self.c return r
cdef ntl_GF2EX _new(self): cdef ntl_GF2EX r
def modulus_context(self): return self.c
def __dealloc__(self):
def __reduce__(self): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0 1] [1 0 0 1] [1]]') sage: f == loads(dumps(f)) True """
def __richcmp__(ntl_GF2EX self, other, int op): """ Compare self to other.
EXAMPLES::
sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0 1] [1 0 0 1] [1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1] [1 1] [1] [0 0 1]]') sage: f == f True sage: f == g False sage: f == "??" False """
raise TypeError("elements of GF(2^e)[X] are not ordered")
cdef ntl_GF2EX b
def __repr__(self): """ Return the string representation of self.
EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: ntl.GF2EX(ctx, '[[1 0] [2 1]]').__repr__() '[[1] [0 1]]' """
def __mul__(ntl_GF2EX self, other): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') sage: f*g ## indirect doctest [[1 0 1 1] [0 0 1 1] [1 0 0 1 0 1] [0 1 0 1]] """ cdef ntl_GF2EX y other = ntl_GF2EX(self.c, other)
def __sub__(ntl_GF2EX self, other): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') sage: f-g ## indirect doctest [[0 0 1 1] [0 0 1 0 1] [1 0 1]] """ cdef ntl_GF2EX y other = ntl_GF2EX(self.c, other)
def __add__(ntl_GF2EX self, other): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') sage: f+g ## indirect doctest [[0 0 1 1] [0 0 1 0 1] [1 0 1]] """ cdef ntl_GF2EX y other = ntl_GF2EX(self.c, other)
def __neg__(ntl_GF2EX self): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: -f ## indirect doctest [[1] [0 1]] """
def __pow__(ntl_GF2EX self, long e, ignored): """ EXAMPLES: sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: f**2 ## indirect doctest [[1] [] [0 0 1]] """ |