linbox
GF2 Class Reference

#include <gf2.h>

Public Types

typedef bool Element
 Element type.
 
typedef BitVector::pointer Element_ptr
 
typedef BitVector::const_pointer ConstElement_ptr
 
typedef bool Residu_t
 
typedef GF2RandIter RandIter
 Random iterator generator type.
 

Public Member Functions

Object Management
 GF2 ()
 Default constructor.
 
 GF2 (int p, int exp=1)
 Default constructor.
 
 GF2 (const GF2 &F)
 Copy constructor.
 
GF2operator= (const GF2 &F)
 Assignment operator.
 
Elementinit (Element &x, const int64_t &y) const
 Initialization of field base element from an integer.
 
Elementinit (Element &x, const uint64_t &y) const
 Default constructor.
 
Elementinit (Element &x, const bool &y) const
 Default constructor.
 
Elementinit (Element &x, const double &y) const
 Default constructor.
 
Elementinit (Element &x, const integer &y) const
 Default constructor.
 
Elementinit (Element &x) const
 Default constructor.
 
BitVector::reference init (BitVector::reference x, const integer &y=0) const
 Default constructor.
 
std::vector< bool >::reference init (std::vector< bool >::reference x, const integer &y=0) const
 Default constructor.
 
integerconvert (integer &x, Element y) const
 Conversion of field base element to a template class T.
 
std::vector< bool >::reference convert (std::vector< bool >::reference x, Element y) const
 Default constructor.
 
template<class XXX>
XXX & convert (XXX &x, Element y) const
 Default constructor.
 
Elementassign (Element &x, Element y) const
 Assignment of one field base element to another.
 
BitVector::reference assign (BitVector::reference x, Element y) const
 Default constructor.
 
std::vector< bool >::reference assign (std::vector< bool >::reference x, Element y) const
 Default constructor.
 
integercardinality (integer &c) const
 Cardinality.
 
integercharacteristic (integer &c) const
 Characteristic.
 
Arithmetic Operations

x <- y op z; x <- op y These operations require all elements, including x, to be initialized before the operation is called.

Uninitialized field base elements will give undefined results.

bool areEqual (Element x, Element y) const
 Equality of two elements.
 
bool isZero (Element x) const
 Zero equality.
 
bool isOne (Element x) const
 One equality.
 
bool isMOne (Element x) const
 MOne equality.
 
bool isUnit (Element x) const
 Invertibility.
 
Elementadd (Element &x, Element y, Element z) const
 Addition.
 
BitVector::reference add (BitVector::reference x, Element y, Element z) const
 Addition.
 
std::vector< bool >::reference add (std::vector< bool >::reference x, Element y, Element z) const
 Addition.
 
Elementsub (Element &x, Element y, Element z) const
 Subtraction.
 
BitVector::reference sub (BitVector::reference x, Element y, Element z) const
 Subtraction.
 
std::vector< bool >::reference sub (std::vector< bool >::reference x, Element y, Element z) const
 Subtraction.
 
Elementmul (Element &x, Element y, Element z) const
 Multiplication.
 
BitVector::reference mul (BitVector::reference x, Element y, Element z) const
 Multiplication.
 
std::vector< bool >::reference mul (std::vector< bool >::reference x, Element y, Element z) const
 Multiplication.
 
Elementdiv (Element &x, Element y, Element z) const
 Division.
 
BitVector::reference div (BitVector::reference x, Element y, Element z) const
 Division.
 
std::vector< bool >::reference div (std::vector< bool >::reference x, Element y, Element z) const
 Division.
 
Elementneg (Element &x, Element y) const
 Additive Inverse (Negation).
 
BitVector::reference neg (BitVector::reference x, Element y) const
 Additive Inverse (Negation).
 
std::vector< bool >::reference neg (std::vector< bool >::reference x, Element y) const
 Additive Inverse (Negation).
 
Elementinv (Element &x, Element y) const
 Multiplicative Inverse.
 
BitVector::reference inv (BitVector::reference x, Element y) const
 Multiplicative Inverse.
 
std::vector< bool >::reference inv (std::vector< bool >::reference x, Element y) const
 Multiplicative Inverse.
 
BitVector::reference axpy (BitVector::reference r, Element a, Element x, Element y) const
 Natural AXPY.
 
std::vector< bool >::reference axpy (std::vector< bool >::reference r, Element a, Element x, Element y) const
 Natural AXPY.
 
Elementaxpy (Element &r, Element a, Element x, Element y) const
 Natural AXPY.
 
Input/Output Operations
std::ostream & write (std::ostream &os) const
 Print field.
 
std::istream & read (std::istream &is)
 Read field.
 
std::ostream & write (std::ostream &os, Element x) const
 Print field base element.
 
std::istream & read (std::istream &is, Element &x) const
 Read field base element.
 
std::istream & read (std::istream &is, BitVector::reference x) const
 Read field base element.
 
std::istream & read (std::istream &is, std::vector< bool >::reference x) const
 Read field base element.
 

Data Fields

const bool zero
 
const bool one
 
const bool mOne
 

Inplace Arithmetic Operations

x <- x op y; x <- op x

Elementaddin (Element &x, Element y) const
 Inplace Addition.
 
BitVector::reference addin (BitVector::reference x, Element y) const
 Inplace Addition.
 
std::vector< bool >::reference addin (std::vector< bool >::reference x, Element y) const
 Inplace Addition.
 
Elementsubin (Element &x, Element y) const
 Inplace Subtraction.
 
BitVector::reference subin (BitVector::reference x, Element y) const
 Inplace Subtraction.
 
std::vector< bool >::reference subin (std::vector< bool >::reference x, Element y) const
 Inplace Subtraction.
 
Elementmulin (Element &x, Element y) const
 Inplace Multiplication.
 
BitVector::reference mulin (BitVector::reference x, Element y) const
 Inplace Multiplication.
 
std::vector< bool >::reference mulin (std::vector< bool >::reference x, Element y) const
 Inplace Multiplication.
 
Elementdivin (Element &x, Element y) const
 Inplace Division.
 
BitVector::reference divin (BitVector::reference x, Element y) const
 Inplace Division.
 
std::vector< bool >::reference divin (std::vector< bool >::reference x, Element y) const
 Inplace Division.
 
Elementnegin (Element &x) const
 Inplace Additive Inverse (Inplace Negation).
 
BitVector::reference negin (BitVector::reference x) const
 Inplace Additive Inplace (Inplace Negation).
 
std::vector< bool >::reference negin (std::vector< bool >::reference x) const
 Inplace Additive Inplace (Inplace Negation).
 
Elementinvin (Element &x) const
 Inplace Multiplicative Inverse.
 
BitVector::reference invin (BitVector::reference x) const
 Inplace Multiplicative Inverse.
 
std::vector< bool >::reference invin (std::vector< bool >::reference x) const
 Inplace Multiplicative Inverse.
 
Elementaxpyin (Element &r, Element a, Element x) const
 Inplace AXPY.
 
BitVector::reference axpyin (BitVector::reference r, Element a, Element x) const
 Inplace AXPY.
 
std::vector< bool >::reference axpyin (std::vector< bool >::reference r, Element a, Element x) const
 Inplace AXPY.
 
Elementaxpyin (Element &r, const std::vector< bool >::reference a, Element x) const
 Inplace AXPY.
 
std::vector< bool >::reference axpyin (std::vector< bool >::reference r, const std::vector< bool >::reference a, Element x) const
 Inplace AXPY.
 
Elementaxpyin (Element &r, Element a, const std::vector< bool >::reference x) const
 Inplace AXPY.
 
std::vector< bool >::reference axpyin (std::vector< bool >::reference r, Element a, const std::vector< bool >::reference x) const
 Inplace AXPY.
 
Elementaxpyin (Element &r, const std::vector< bool >::reference a, const std::vector< bool >::reference x) const
 Inplace AXPY.
 
std::vector< bool >::reference axpyin (std::vector< bool >::reference r, const std::vector< bool >::reference a, const std::vector< bool >::reference x) const
 Inplace AXPY.
 
static int maxCardinality ()
 Inplace Addition.
 

Detailed Description

Member Typedef Documentation

◆ Element

typedef bool Element

Element type.

◆ Element_ptr

◆ ConstElement_ptr

◆ Residu_t

typedef bool Residu_t

◆ RandIter

Random iterator generator type.

It must meet the common object interface of random element generators as given in the the archetype RandIterArchetype.

Constructor & Destructor Documentation

◆ GF2() [1/3]

GF2 ( )
inline

Default constructor.

◆ GF2() [2/3]

GF2 ( int p,
int exp = 1 )
inline

Default constructor.

◆ GF2() [3/3]

GF2 ( const GF2 & F)
inline

Copy constructor.

Constructs Givaro::Modular object by copying the field. This is required to allow field objects to be passed by value into functions.

Parameters
FGivaro::Modular object.

Member Function Documentation

◆ operator=()

GF2 & operator= ( const GF2 & F)
inline

Assignment operator.

Required by the archetype

Parameters
Fconstant reference to Givaro::Modular object
Returns
reference to Givaro::Modular object for self

◆ init() [1/8]

Element & init ( Element & x,
const int64_t & y ) const
inline

Initialization of field base element from an integer.

Behaves like C++ allocator construct. This function assumes the output field base element x has already been constructed, but that it is not already initialized. This is not a specialization of the template function because such a specialization is not allowed inside the class declaration.

Returns
reference to field base element.
Parameters
xfield base element to contain output (reference returned).
yinteger.

◆ init() [2/8]

Element & init ( Element & x,
const uint64_t & y ) const
inline

Default constructor.

◆ init() [3/8]

Element & init ( Element & x,
const bool & y ) const
inline

Default constructor.

◆ init() [4/8]

Element & init ( Element & x,
const double & y ) const
inline

Default constructor.

◆ init() [5/8]

Element & init ( Element & x,
const integer & y ) const
inline

Default constructor.

◆ init() [6/8]

Element & init ( Element & x) const
inline

Default constructor.

◆ init() [7/8]

BitVector::reference init ( BitVector::reference x,
const integer & y = 0 ) const
inline

Default constructor.

◆ init() [8/8]

std::vector< bool >::reference init ( std::vector< bool >::reference x,
const integer & y = 0 ) const
inline

Default constructor.

◆ convert() [1/3]

integer & convert ( integer & x,
Element y ) const
inline

Conversion of field base element to a template class T.

This function assumes the output field base element x has already been constructed, but that it is not already initialized.

Returns
reference to template class T.
Parameters
xtemplate class T to contain output (reference returned).
yconstant field base element.

◆ convert() [2/3]

std::vector< bool >::reference convert ( std::vector< bool >::reference x,
Element y ) const
inline

Default constructor.

◆ convert() [3/3]

template<class XXX>
XXX & convert ( XXX & x,
Element y ) const
inline

Default constructor.

◆ assign() [1/3]

Element & assign ( Element & x,
Element y ) const
inline

Assignment of one field base element to another.

This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x
Parameters
xfield base element (reference returned).
yfield base element.

◆ assign() [2/3]

BitVector::reference assign ( BitVector::reference x,
Element y ) const
inline

Default constructor.

◆ assign() [3/3]

std::vector< bool >::reference assign ( std::vector< bool >::reference x,
Element y ) const
inline

Default constructor.

◆ cardinality()

integer & cardinality ( integer & c) const
inline

Cardinality.

Return integer representing cardinality of the domain. Returns a non-negative integer for all domains with finite cardinality, and returns -1 to signify a domain of infinite cardinality.

Returns
integer representing cardinality of the domain

◆ characteristic()

integer & characteristic ( integer & c) const
inline

Characteristic.

Return integer representing characteristic of the domain. Returns a positive integer to all domains with finite characteristic, and returns 0 to signify a domain of infinite characteristic.

Returns
integer representing characteristic of the domain.

◆ areEqual()

bool areEqual ( Element x,
Element y ) const
inline

Equality of two elements.

This function assumes both field base elements have already been constructed and initialized.

Returns
boolean true if equal, false if not.
Parameters
xfield base element
yfield base element

◆ isZero()

bool isZero ( Element x) const
inline

Zero equality.

Test if field base element is equal to zero. This function assumes the field base element has already been constructed and initialized.

Returns
boolean true if equals zero, false if not.
Parameters
xfield base element.

◆ isOne()

bool isOne ( Element x) const
inline

One equality.

Test if field base element is equal to one. This function assumes the field base element has already been constructed and initialized.

Returns
boolean true if equals one, false if not.
Parameters
xfield base element.

◆ isMOne()

bool isMOne ( Element x) const
inline

MOne equality.

Test if field base element is equal to one. This function assumes the field base element has already been constructed and initialized.

Returns
boolean true if equals one, false if not.
Parameters
xfield base element.

◆ isUnit()

bool isUnit ( Element x) const
inline

Invertibility.

Test if field base element is a unit. This function assumes the field base element has already been constructed and initialized.

Returns
boolean true if is a unit, false if not.
Parameters
xfield base element.

◆ write() [1/2]

std::ostream & write ( std::ostream & os) const
inline

Print field.

Returns
output stream to which field is written.
Parameters
osoutput stream to which field is written.

◆ read() [1/4]

std::istream & read ( std::istream & is)
inline

Read field.

Returns
input stream from which field is read.
Parameters
isinput stream from which field is read.

◆ write() [2/2]

std::ostream & write ( std::ostream & os,
Element x ) const
inline

Print field base element.

This function assumes the field base element has already been constructed and initialized.

Returns
output stream to which field base element is written.
Parameters
osoutput stream to which field base element is written.
xfield base element.

◆ read() [2/4]

std::istream & read ( std::istream & is,
Element & x ) const
inline

Read field base element.

Precondition
This function assumes the field base element has already been constructed and initialized.
Returns
input stream from which field base element is read.
Parameters
isinput stream from which field base element is read.
xfield base element.

◆ read() [3/4]

std::istream & read ( std::istream & is,
BitVector::reference x ) const
inline

Read field base element.

Parameters
isinput stream
x
Returns
is

◆ read() [4/4]

std::istream & read ( std::istream & is,
std::vector< bool >::reference x ) const
inline

Read field base element.

Parameters
isinput stream
x
Returns
is

◆ add() [1/3]

Element & add ( Element & x,
Element y,
Element z ) const
inline

Addition.

x = y + z This function assumes all the field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.
zfield base element.

◆ add() [2/3]

Addition.

Parameters
x
y
z

◆ add() [3/3]

std::vector< bool >::reference add ( std::vector< bool >::reference x,
Element y,
Element z ) const
inline

Addition.

Parameters
x
y
z

◆ sub() [1/3]

Element & sub ( Element & x,
Element y,
Element z ) const
inline

Subtraction.

x = y - z This function assumes all the field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.
zfield base element.

◆ sub() [2/3]

Subtraction.

Parameters
x
y
z

◆ sub() [3/3]

std::vector< bool >::reference sub ( std::vector< bool >::reference x,
Element y,
Element z ) const
inline

Subtraction.

Parameters
x
y
z

◆ mul() [1/3]

Element & mul ( Element & x,
Element y,
Element z ) const
inline

Multiplication.

x = y * z This function assumes all the field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.
zfield base element.

◆ mul() [2/3]

Multiplication.

Parameters
x
y
z

◆ mul() [3/3]

std::vector< bool >::reference mul ( std::vector< bool >::reference x,
Element y,
Element z ) const
inline

Multiplication.

Parameters
x
y
z

◆ div() [1/3]

Element & div ( Element & x,
Element y,
Element z ) const
inline

Division.

x = y / z This function assumes all the field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.
zfield base element.
Bug
z is unused

◆ div() [2/3]

Division.

Parameters
x
y
z

◆ div() [3/3]

std::vector< bool >::reference div ( std::vector< bool >::reference x,
Element y,
Element z ) const
inline

Division.

Parameters
x
y
z

◆ neg() [1/3]

Element & neg ( Element & x,
Element y ) const
inline

Additive Inverse (Negation).

x = - y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

◆ neg() [2/3]

Additive Inverse (Negation).

Returns
reference to x.
Parameters
x
y

◆ neg() [3/3]

std::vector< bool >::reference neg ( std::vector< bool >::reference x,
Element y ) const
inline

Additive Inverse (Negation).

Returns
reference to x.
Parameters
x
y

◆ inv() [1/3]

Element & inv ( Element & x,
Element y ) const
inline

Multiplicative Inverse.

x = 1 / y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

◆ inv() [2/3]

Multiplicative Inverse.

Returns
reference to x.
Parameters
x
y

◆ inv() [3/3]

std::vector< bool >::reference inv ( std::vector< bool >::reference x,
Element y ) const
inline

Multiplicative Inverse.

Returns
reference to x.
Parameters
x
y

◆ axpy() [1/3]

Natural AXPY.

r = a * x + y This function assumes all field elements have already been constructed and initialized.

Returns
reference to r.
Parameters
rfield element (reference returned).
afield element.
xfield element.
yfield element.

◆ axpy() [2/3]

std::vector< bool >::reference axpy ( std::vector< bool >::reference r,
Element a,
Element x,
Element y ) const
inline

Natural AXPY.

Returns
reference to r.
Parameters
r
a
x
y

◆ axpy() [3/3]

Element & axpy ( Element & r,
Element a,
Element x,
Element y ) const
inline

Natural AXPY.

Returns
reference to r.
Parameters
r
a
x
y

◆ addin() [1/3]

Element & addin ( Element & x,
Element y ) const
inline

Inplace Addition.

x += y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

◆ addin() [2/3]

BitVector::reference addin ( BitVector::reference x,
Element y ) const
inline

Inplace Addition.

Returns
reference to x.
Parameters
x
y

◆ addin() [3/3]

std::vector< bool >::reference addin ( std::vector< bool >::reference x,
Element y ) const
inline

Inplace Addition.

Returns
reference to x.
Parameters
x
y

◆ subin() [1/3]

Element & subin ( Element & x,
Element y ) const
inline

Inplace Subtraction.

x -= y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

◆ subin() [2/3]

BitVector::reference subin ( BitVector::reference x,
Element y ) const
inline

Inplace Subtraction.

Returns
reference to x.
Parameters
x
y

◆ subin() [3/3]

std::vector< bool >::reference subin ( std::vector< bool >::reference x,
Element y ) const
inline

Inplace Subtraction.

Returns
reference to x.
Parameters
x
y

◆ mulin() [1/3]

Element & mulin ( Element & x,
Element y ) const
inline

Inplace Multiplication.

x *= y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

◆ mulin() [2/3]

BitVector::reference mulin ( BitVector::reference x,
Element y ) const
inline

Inplace Multiplication.

Returns
reference to x.
Parameters
x
y

◆ mulin() [3/3]

std::vector< bool >::reference mulin ( std::vector< bool >::reference x,
Element y ) const
inline

Inplace Multiplication.

Returns
reference to x.
Parameters
x
y

◆ divin() [1/3]

Element & divin ( Element & x,
Element y ) const
inline

Inplace Division.

x /= y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.
Bug
y is unused

◆ divin() [2/3]

BitVector::reference divin ( BitVector::reference x,
Element y ) const
inline

Inplace Division.

Returns
reference to x.
Parameters
x
y
Bug
y is unused

◆ divin() [3/3]

std::vector< bool >::reference divin ( std::vector< bool >::reference x,
Element y ) const
inline

Inplace Division.

Returns
reference to x.
Parameters
x
y
Bug
y is unused

◆ negin() [1/3]

Element & negin ( Element & x) const
inline

Inplace Additive Inverse (Inplace Negation).

x = - x This function assumes the field base element has already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).

◆ negin() [2/3]

BitVector::reference negin ( BitVector::reference x) const
inline

Inplace Additive Inplace (Inplace Negation).

Returns
reference to x.
Parameters
x
Bug
y is unused

◆ negin() [3/3]

std::vector< bool >::reference negin ( std::vector< bool >::reference x) const
inline

Inplace Additive Inplace (Inplace Negation).

Returns
reference to x.
Parameters
x
Bug
y is unused

◆ invin() [1/3]

Element & invin ( Element & x) const
inline

Inplace Multiplicative Inverse.

x = 1 / x This function assumes the field base elementhas already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).

◆ invin() [2/3]

BitVector::reference invin ( BitVector::reference x) const
inline

Inplace Multiplicative Inverse.

Returns
reference to x.
Parameters
x

◆ invin() [3/3]

std::vector< bool >::reference invin ( std::vector< bool >::reference x) const
inline

Inplace Multiplicative Inverse.

Returns
reference to x.
Parameters
x

◆ axpyin() [1/9]

Element & axpyin ( Element & r,
Element a,
Element x ) const
inline

Inplace AXPY.

r += a * x This function assumes all field elements have already been constructed and initialized. Purely virtual

Returns
reference to r.
Parameters
rfield element (reference returned).
afield element.
xfield element.

◆ axpyin() [2/9]

BitVector::reference axpyin ( BitVector::reference r,
Element a,
Element x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [3/9]

std::vector< bool >::reference axpyin ( std::vector< bool >::reference r,
Element a,
Element x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [4/9]

Element & axpyin ( Element & r,
const std::vector< bool >::reference a,
Element x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [5/9]

std::vector< bool >::reference axpyin ( std::vector< bool >::reference r,
const std::vector< bool >::reference a,
Element x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [6/9]

Element & axpyin ( Element & r,
Element a,
const std::vector< bool >::reference x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [7/9]

std::vector< bool >::reference axpyin ( std::vector< bool >::reference r,
Element a,
const std::vector< bool >::reference x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [8/9]

Element & axpyin ( Element & r,
const std::vector< bool >::reference a,
const std::vector< bool >::reference x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ axpyin() [9/9]

std::vector< bool >::reference axpyin ( std::vector< bool >::reference r,
const std::vector< bool >::reference a,
const std::vector< bool >::reference x ) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
r
a
x

◆ maxCardinality()

static int maxCardinality ( )
inlinestatic

Inplace Addition.

x += y This function assumes both field base elements have already been constructed and initialized.

Returns
reference to x.
Parameters
xfield base element (reference returned).
yfield base element.

Field Documentation

◆ zero

const bool zero

◆ one

const bool one

◆ mOne

const bool mOne

The documentation for this class was generated from the following file: