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) 2007 Martin Albrecht <malb@informatik.uni-bremen.de> # # 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 division
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 sage.rings.integer cimport Integer from sage.rings.integer_ring cimport IntegerRing_class
############################################################################## # GF2: Bits ##############################################################################
cdef class ntl_GF2(object): r""" The \class{GF2} represents the field GF(2). Computationally speaking, it is not a particularly useful class. Its main use is to make the interfaces to the various finite field classes as uniform as possible. """ def __init__(self, v=None): r""" Initializes a NTL bit.
EXAMPLES: sage: ntl.GF2(1) 1 sage: ntl.GF2(int(2)) 0 sage: ntl.GF2('1') 1 """ self.x = (<ntl_GF2>v).x
def __repr__(self): """ Return the string representation of self.
EXAMPLES: sage: str(ntl.GF2(1)) # indirect doctest '1' """
def __reduce__(self): """ Serializes self.
EXAMPLES: sage: a = ntl.GF2(1) sage: loads(dumps(a)) 1 """
def __richcmp__(ntl_GF2 self, other, int op): """ Compare self to other.
EXAMPLES::
sage: a = ntl.GF2(1) sage: b = ntl.GF2(0) sage: a == a True sage: a == b False sage: a == 1 True sage: a < b Traceback (most recent call last): ... TypeError: elements of GF(2) are not ordered """
cdef ntl_GF2 b
def __mul__(self, other): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: o*o 1 sage: o*z 0 sage: z*o 0 sage: z*z 0 """ self = ntl_GF2(self) other = ntl_GF2(other)
def __truediv__(self, other): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: o/o 1 sage: o/z Traceback (most recent call last): ... ZeroDivisionError """ cdef ntl_GF2 r self = ntl_GF2(self) other = ntl_GF2(other)
def __div__(self, other):
def __sub__(self, other): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: o-o 0 sage: o-z 1 sage: z-o 1 sage: z-z 0 """ self = ntl_GF2(self) other = ntl_GF2(other)
def __add__(self, other): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: o+o 0 sage: o+z 1 sage: z+o 1 sage: z+z 0 """ self = ntl_GF2(self)
def __neg__(ntl_GF2 self): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: -z 0 sage: -o 1 """
def __pow__(ntl_GF2 self, long e, ignored): """ sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: z^2 0 sage: o^2 1 """
def __int__(self): """ Return self as an int.
EXAMPLES: sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: int(z) 0 sage: int(o) 1 """
def unpickle_class_value(cls, x): """ Here for unpickling.
EXAMPLES: sage: sage.libs.ntl.ntl_GF2.unpickle_class_value(ntl.GF2,1) 1 sage: type(sage.libs.ntl.ntl_GF2.unpickle_class_value(ntl.GF2,1)) <type 'sage.libs.ntl.ntl_GF2.ntl_GF2'> """
def unpickle_class_args(cls, x): """ Here for unpickling.
EXAMPLES: sage: sage.libs.ntl.ntl_GF2.unpickle_class_args(ntl.GF2,[1]) 1 sage: type(sage.libs.ntl.ntl_GF2.unpickle_class_args(ntl.GF2,[1])) <type 'sage.libs.ntl.ntl_GF2.ntl_GF2'> """
|