Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

GF2 Class Template Reference

Template class for Galois fields of size . More...

#include <gf2.H>

List of all members.

Public Methods

 GF2 ()
 Default constructor. Returns the "zero" of the field.

 GF2 (int n)
 Conversion int -> GF<n>. Returns "one" added to itself n times.

bool is_zero () const
 Is this the "zero"?

bool is_one () const
 Is this the "one"?

bool is_unit () const
 Does this element have a multiplicative inverse?

const bool is_euclidean ()
 Does this element belong to an Euclidean ring?

unsigned int deg () const
 My degree (it makes sense only if is_euclidean()==true).

GF2<FieldSize> operator+ (GF2< FieldSize > b) const
 Sum.

bool operator== (GF2< FieldSize > b) const
 Equality.

bool operator!= (GF2< FieldSize > b) const
 Inequality.

GF2<FieldSize> operator- (GF2< FieldSize > b) const
 Difference.

GF2<FieldSize> operator- () const
 Minus.

GF2<FieldSize> operator * (GF2< FieldSize > b) const
 Product.

void divmod (GF2< FieldSize > a, GF2< FieldSize > &quot, GF2< FieldSize > &rem)
 Division and remainder. Since GF<n> is a field, rem==0.


Static Public Methods

GF2<FieldSize> zero ()
 "zero" constructor.

GF2<FieldSize> one ()
 "one" constructor.

const bool is_field ()
 Is this a field?

GF2<FieldSize> string2val (std::string str)
 Conversion from string to GF<n>.

void regexp (std::string &re, int &idx)
 Regular expression rappresenting an element of GF<>.


Friends

GF2<FieldSize> inv (GF2< FieldSize > x)
 Multiplicative inverse (it makes sense only if is_unit()==true).

std::ostream& operator<< (std::ostream &str, GF2< FieldSize > n)
 Output operator.

std::istream& operator>> (std::istream &str, GF2< FieldSize > &n)
 Input operator.

bool operator>> (char *str, GF2< FieldSize > &n)
 Input from strings.


Detailed Description

template<int FieldSize> class GF2

Template class for Galois fields of size .

This is a template for a class which implements a Galois field of size . It is not as general as GF, but it is more efficient since each element is stored as an unsigned integer.

Typical usage

    GF2<16> x, y;            // x and y are values in GF(16)
    std::cin >> x >> y;      // read x and y from stdin
    std::cout << x+inv(y);   // write x+1/y to stdout


The documentation for this class was generated from the following file:
Generated at Mon Oct 11 14:57:41 2004 for GaloisLib by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001