/usr/share/doc/libntl-dev/NTL/GF2.txt is in libntl-dev 9.9.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | /**************************************************************************\
MODULE: GF2
SUMMARY:
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.
The header file for GF2 also declares the class ref_GF2, which
use used to represent non-const references to GF2's, such as
those obtained from indexing a vec_GF2, which "packs" GF2's
into words.
There are implicit conversions from ref_GF2 to const GF2
and from GF2& to ref_GF2. Therefore, if you want to declare
a function that takes a non-const reference to a GF2, you
should declare the parameter of type ref_GF2: this will
allow you to pass variables of type GF2 as well as
elements of vec_GF2's obtained through indexing.
For all functions defined below which take a parameter of type
GF2&, there is also a function that takes a parameter of type ref_GF2.
Theoretically, we could have just defined the functions that take
the ref_GF2 parameter type, because of the implicit conversion
from GF2& to ref_GF2; however, for efficiency reasons, both
flavors are actually provided. It is recommended that higher-level
functions use the ref_GF2 type exclusively.
\**************************************************************************/
#include <NTL/ZZ.h>
#include <NTL/vector.h>
class GF2 {
public:
GF2(); // initial value 0
GF2(const GF2& a); // copy constructor
explicit GF2(long a); // promotion constructor
GF2& operator=(const GF2& a); // assignment
GF2& operator=(long a); // assignment
// typedefs to aid in generic programming
typedef long rep_type;
typedef GF2Context context_type;
typedef GF2Bak bak_type;
typedef GF2Push push_type;
typedef GF2X poly_type;
};
long rep(GF2 a); // read-only access to representation of a
/**************************************************************************\
Comparison
\**************************************************************************/
long operator==(GF2 a, GF2 b);
long operator!=(GF2 a, GF2 b);
long IsZero(GF2 a); // test for 0
long IsOne(GF2 a); // test for 1
// PROMOTIONS: operators ==, != promote long to GF2 on (a, b).
/**************************************************************************\
Addition
\**************************************************************************/
// operator notation:
GF2 operator+(GF2 a, GF2 b);
GF2 operator-(GF2 a, GF2 b);
GF2 operator-(GF2 a); // unary -
GF2& operator+=(GF2& x, GF2 a);
GF2& operator+=(GF2& x, long a);
GF2& operator-=(GF2& x, GF2 a);
GF2& operator-=(GF2& x, long a);
GF2& operator++(GF2& x); // prefix
void operator++(GF2& x, int); // postfix
GF2& operator--(GF2& x); // prefix
void operator--(GF2& x, int); // postfix
// procedural versions:
void add(GF2& x, GF2 a, GF2 b); // x = a + b
void sub(GF2& x, GF2 a, GF2 b); // x = a - b
void negate(GF2& x, GF2 a); // x = -a
// PROMOTIONS: binary +, -, and procedures add, sub promote
// from long to GF2 on (a, b).
/**************************************************************************\
Multiplication
\**************************************************************************/
// operator notation:
GF2 operator*(GF2 a, GF2 b);
GF2& operator*=(GF2& x, GF2 a);
GF2& operator*=(GF2& x, long a);
// procedural versions:
void mul(GF2& x, GF2 a, GF2 b); // x = a * b
void sqr(GF2& x, GF2 a); // x = a^2
GF2 sqr(GF2 a);
// PROMOTIONS: operator * and procedure mul promote from long to GF2
// on (a, b).
/**************************************************************************\
Division
\**************************************************************************/
operator notation:
GF2 operator/(z_p a, GF2 b);
GF2& operator/=(GF2& x, GF2 a);
GF2& operator/=(GF2& x, long a);
procedural versions:
void div(GF2& x, GF2 a, GF2 b);
// x = a/b
void inv(GF2& x, GF2 a);
GF2 inv(GF2 a);
// x = 1/a
// PROMOTIONS: operator / and procedure div promote from long to GF2
// on (a, b).
/**************************************************************************\
Exponentiation
\**************************************************************************/
void power(GF2& x, GF2 a, long e); // x = a^e (e may be negative)
GF2 power(GF2 a, long e);
/**************************************************************************\
Random Elements
\**************************************************************************/
void random(GF2& x);
GF2 random_GF2();
// x = random element in GF2. Uses RandomBnd from ZZ.
/**************************************************************************\
Input/Output
\**************************************************************************/
ostream& operator<<(ostream& s, GF2 a);
istream& operator>>(istream& s, GF2& x);
// a ZZ is read and reduced mod 2
/**************************************************************************\
Miscellany
\**************************************************************************/
void clear(GF2& x); // x = 0
void set(GF2& x); // x = 1
void GF2::swap(GF2& x);
void swap(GF2& x, GF2& y);
// swap
static GF2 GF2::zero();
// GF2::zero() yields a read-only reference to zero
static long GF2::modulus();
// GF2::modulus() returns the value 2
template<> class Vec<GF2>;
// Forward declaration of the explicit specialization
// of Vec<GF2>. This specialization is defined in <NTL/vec_GF2.h>,
// which must be included in source files that need to use Vec<GF2>.
GF2::GF2(INIT_NO_ALLOC_TYPE);
// provided for consistency with other classes, initialize to zero
GF2::GF2(INIT_ALLOC_TYPE);
// provided for consistency with other classes, initialize to zero
GF2::allocate();
// provided for consistency with other classes, no action
|