Givaro
Public Types
GF2 Class Referenceabstract

Integers modulo 2. More...

#include <gf2.h>

Inherits FiniteFieldInterface< _Element >.

Public Types

using Self_t = GF2
 Element type.
 
using RandIter = GIV_randIter< Self_t, bool >
 Random.
 

Public Member Functions

Object Management
 GF2 ()
 Default constructor.
 
 GF2 (int p, int exp=1)
 Default constructor.
 
 GF2 (const GF2 &F)
 Copy constructor. More...
 
GF2operator= (const GF2 &F)
 Assignment operator. More...
 
Element minElement () const
 Accessors.
 
Element maxElement () const
 Default constructor.
 
Residu_t residu () const
 Access to the modulus.
 
Residu_t size () const
 Default constructor.
 
Residu_t characteristic () const
 Default constructor.
 
Residu_t cardinality () const
 Default constructor.
 
template<class T >
T & characteristic (T &p) const
 Default constructor.
 
template<class T >
T & cardinality (T &p) const
 Default constructor.
 
Element & init (Element &x, const int &y) const
 Initialization of field base element from an Integer. More...
 
Element & init (Element &x, const unsigned int &y) const
 Default constructor.
 
Element & init (Element &x, const long &y) const
 Default constructor.
 
Element & init (Element &x, const unsigned long &y) const
 Default constructor.
 
Element & init (Element &x, const float &y) const
 Default constructor.
 
Element & init (Element &x, const double &y) const
 Default constructor.
 
Element & init (Element &x, const Integer &y) const
 Default constructor.
 
Element & init (Element &x) const
 Default constructor.
 
BitReference init (BitReference x, const Integer &y=0) const
 Default constructor.
 
Integerconvert (Integer &x, const Element &y) const
 Conversion of field base element to a template class T. More...
 
BitReference convert (BitReference x, const Element &y) const
 Default constructor.
 
template<class T >
T & convert (T &x, const Element &y) const
 Default constructor.
 
Element & assign (Element &x, const Element &y) const
 Assignment of one field base element to another. More...
 
BitReference assign (BitReference x, const Element &y) const
 Default constructor.
 
Integercardinality (Integer &c) const
 Cardinality. More...
 
Integercharacteristic (Integer &c) const
 Characteristic. More...
 
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 (const Element &x, const Element &y) const
 Equality of two elements. More...
 
bool isZero (const Element &x) const
 Zero equality. More...
 
bool isOne (const Element &x) const
 One equality. More...
 
bool isMOne (const Element &x) const
 MOne equality. More...
 
Element & add (Element &x, const Element &y, const Element &z) const
 Addition. More...
 
BitReference add (BitReference x, const Element &y, const Element &z) const
 Equality of two elements. More...
 
Element & sub (Element &x, const Element &y, const Element &z) const
 Subtraction. More...
 
BitReference sub (BitReference x, const Element &y, const Element &z) const
 Equality of two elements. More...
 
Element & mul (Element &x, const Element &y, const Element &z) const
 Multiplication. More...
 
BitReference mul (BitReference x, const Element &y, const Element &z) const
 Equality of two elements. More...
 
Element & div (Element &x, const Element &y, const Element &z) const
 Division. More...
 
BitReference div (BitReference x, const Element &y, const Element &z) const
 Equality of two elements. More...
 
Element & neg (Element &x, const Element &y) const
 Additive Inverse (Negation). More...
 
BitReference neg (BitReference x, const Element &y) const
 Equality of two elements. More...
 
Element & inv (Element &x, const Element &y) const
 Multiplicative Inverse. More...
 
BitReference inv (BitReference x, const Element &y) const
 Equality of two elements. More...
 
BitReference axpy (BitReference r, const Element &a, const Element &x, const Element &y) const
 Natural AXPY. More...
 
Element & axpy (Element &r, const Element &a, const Element &x, const Element &y) const
 Equality of two elements. More...
 
BitReference axmy (BitReference r, const Element &a, const Element &x, const Element &y) const
 Natural AXMY. More...
 
Element & axmy (Element &r, const Element &a, const Element &x, const Element &y) const
 Equality of two elements. More...
 
BitReference maxpy (BitReference r, const Element &a, const Element &x, const Element &y) const
 Natural MAXPY. More...
 
Element & maxpy (Element &r, const Element &a, const Element &x, const Element &y) const
 Equality of two elements. More...
 
Input/Output Operations
std::ostream & write (std::ostream &os) const
 Print field. More...
 
std::istream & read (std::istream &is)
 Read field. More...
 
std::ostream & write (std::ostream &os, const Element &x) const
 Print field base element. More...
 
std::istream & read (std::istream &is, Element &x) const
 Read field base element. More...
 
std::istream & read (std::istream &is, BitReference x) const
 Print field. More...
 
Inplace Arithmetic Operations

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

Element & addin (Element &x, const Element &y) const
 Inplace Addition. More...
 
BitReference addin (BitReference x, const Element &y) const
 Inplace Addition. More...
 
Element & subin (Element &x, const Element &y) const
 Inplace Subtraction. More...
 
BitReference subin (BitReference x, const Element &y) const
 Inplace Addition. More...
 
Element & mulin (Element &x, const Element &y) const
 Inplace Multiplication. More...
 
BitReference mulin (BitReference x, const Element &y) const
 Inplace Addition. More...
 
Element & divin (Element &x, const Element &y) const
 Inplace Division. More...
 
BitReference divin (BitReference x, const Element &y) const
 Inplace Addition. More...
 
Element & negin (Element &x) const
 Inplace Additive Inverse (Inplace Negation). More...
 
BitReference negin (BitReference x) const
 Inplace Addition. More...
 
Element & invin (Element &x) const
 Inplace Multiplicative Inverse. More...
 
BitReference invin (BitReference x) const
 Inplace Addition. More...
 
Element & axpyin (Element &r, const Element &a, const Element &x) const
 Inplace AXPY. More...
 
BitReference axpyin (BitReference r, const Element &a, const Element &x) const
 Inplace Addition. More...
 
Element & axmyin (Element &r, const Element &a, const Element &x) const
 Inplace AXMY. More...
 
BitReference axmyin (BitReference r, const Element &a, const Element &x) const
 Inplace Addition. More...
 
Element & maxpyin (Element &r, const Element &a, const Element &x) const
 Inplace MAXPY. More...
 
BitReference maxpyin (BitReference r, const Element &a, const Element &x) const
 Inplace Addition. More...
 

Detailed Description

Integers modulo 2.

This is a tuned implementation of the field of integers modulo

  1. In particular, when one constructs a VectorDomain object over this field, highly optimized bit operations will be used to make vector arithmetic very fast.

Constructor & Destructor Documentation

GF2 ( const GF2 F)
inline

Copy constructor.

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

Parameters
FGivaro::GF2 object.

Member Function Documentation

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
Element& init ( Element &  x,
const int &  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.
Integer& convert ( Integer x,
const 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.
Element& assign ( Element &  x,
const 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.
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
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.
bool areEqual ( const Element &  x,
const 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
bool isZero ( const 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.
bool isOne ( const 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.
bool isMOne ( const 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.
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.
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.
std::ostream & write ( std::ostream &  os,
const 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.
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.
std::istream & read ( std::istream &  is,
BitReference  x 
) const
inline

Print field.

Returns
output stream to which field is written.
Parameters
osoutput stream to which field is written.
GF2::Element & add ( Element &  x,
const Element &  y,
const 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.
GF2::BitReference add ( BitReference  x,
const Element &  y,
const Element &  z 
) 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
GF2::Element & sub ( Element &  x,
const Element &  y,
const 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.
GF2::BitReference sub ( BitReference  x,
const Element &  y,
const Element &  z 
) 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
GF2::Element & mul ( Element &  x,
const Element &  y,
const 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.
GF2::BitReference mul ( BitReference  x,
const Element &  y,
const Element &  z 
) 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
GF2::Element & div ( Element &  x,
const Element &  y,
const 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.
GF2::BitReference div ( BitReference  x,
const Element &  y,
const Element &  z 
) 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
GF2::Element & neg ( Element &  x,
const 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.
GF2::BitReference neg ( BitReference  x,
const 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
GF2::Element & inv ( Element &  x,
const 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.
GF2::BitReference inv ( BitReference  x,
const 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
GF2::BitReference axpy ( BitReference  r,
const Element &  a,
const Element &  x,
const Element &  y 
) const
inline

Natural AXPY.

Returns
reference to r.
Parameters
r
a
x
y
GF2::Element & axpy ( Element &  r,
const Element &  a,
const Element &  x,
const 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
GF2::BitReference axmy ( BitReference  r,
const Element &  a,
const Element &  x,
const Element &  y 
) const
inline

Natural AXMY.

Returns
reference to r.
Parameters
r
a
x
y
GF2::Element & axmy ( Element &  r,
const Element &  a,
const Element &  x,
const 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
GF2::BitReference maxpy ( BitReference  r,
const Element &  a,
const Element &  x,
const Element &  y 
) const
inline

Natural MAXPY.

Returns
reference to r.
Parameters
r
a
x
y
GF2::Element & maxpy ( Element &  r,
const Element &  a,
const Element &  x,
const 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
GF2::Element & addin ( Element &  x,
const 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.
GF2::BitReference addin ( BitReference  x,
const 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.
GF2::Element & subin ( Element &  x,
const 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.
GF2::BitReference subin ( BitReference  x,
const 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.
GF2::Element & mulin ( Element &  x,
const 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.
GF2::BitReference mulin ( BitReference  x,
const 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.
GF2::Element & divin ( Element &  x,
const 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.
GF2::BitReference divin ( BitReference  x,
const 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.
GF2::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).
GF2::BitReference negin ( BitReference  x) 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.
GF2::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).
GF2::BitReference invin ( BitReference  x) 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.
GF2::Element & axpyin ( Element &  r,
const Element &  a,
const Element &  x 
) const
inline

Inplace AXPY.

Returns
reference to r.
Parameters
rfield element (reference returned).
afield element.
xfield element.
GF2::BitReference axpyin ( BitReference  r,
const Element &  a,
const Element &  x 
) 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.
GF2::Element & axmyin ( Element &  r,
const Element &  a,
const Element &  x 
) const
inline

Inplace AXMY.

Returns
reference to r.
Parameters
rfield element (reference returned).
afield element.
xfield element.
GF2::BitReference axmyin ( BitReference  r,
const Element &  a,
const Element &  x 
) 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.
GF2::Element & maxpyin ( Element &  r,
const Element &  a,
const Element &  x 
) const
inline

Inplace MAXPY.

Returns
reference to r.
Parameters
rfield element (reference returned).
afield element.
xfield element.
GF2::BitReference maxpyin ( BitReference  r,
const Element &  a,
const Element &  x 
) 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.

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