.
More...
#include <gf2.H>
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 > ", 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. | |
.
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.
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
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001