/usr/include/NTL/GF2.h is in libntl-dev 5.4.2-4.1build1.
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 | #ifndef NTL_GF2__H
#define NTL_GF2__H
#include <NTL/ZZ.h>
NTL_OPEN_NNS
class GF2 {
public:
long _GF2__rep;
GF2() { _GF2__rep = 0; }
GF2(const GF2& a) : _GF2__rep(a._GF2__rep) { }
~GF2() { }
GF2& operator=(const GF2& a) { _GF2__rep = a._GF2__rep; return *this; }
GF2& operator=(long a) { _GF2__rep = a & 1; return *this; }
static long modulus() { return 2; }
static GF2 zero() { return GF2(); }
};
inline void conv(GF2& x, long a) { x._GF2__rep = a & 1; }
inline GF2 to_GF2(long a)
{ GF2 x; conv(x, a); return x; }
inline void conv(GF2& x, const ZZ& a) { x._GF2__rep = IsOdd(a); }
inline GF2 to_GF2(const ZZ& a)
{ GF2 x; conv(x, a); return x; }
inline long rep(GF2 a) { return a._GF2__rep; }
inline void clear(GF2& x) { x._GF2__rep = 0; }
inline void set(GF2& x) { x._GF2__rep = 1; }
inline void swap(GF2& x, GF2& y)
{ long t; t = x._GF2__rep; x._GF2__rep = y._GF2__rep; y._GF2__rep = t; }
inline void add(GF2& x, GF2 a, GF2 b)
{ x._GF2__rep = a._GF2__rep ^ b._GF2__rep; }
inline void sub(GF2& x, GF2 a, GF2 b)
{ x._GF2__rep = a._GF2__rep ^ b._GF2__rep; }
inline void negate(GF2& x, GF2 a)
{ x._GF2__rep = a._GF2__rep; }
inline void add(GF2& x, GF2 a, long b)
{ x._GF2__rep = a._GF2__rep ^ (b & 1); }
inline void add(GF2& x, long a, GF2 b)
{ x._GF2__rep = (a & 1) ^ b._GF2__rep; }
inline void sub(GF2& x, GF2 a, long b)
{ x._GF2__rep = a._GF2__rep ^ (b & 1); }
inline void sub(GF2& x, long a, GF2 b)
{ x._GF2__rep = (a & 1) ^ b._GF2__rep; }
inline GF2 operator+(GF2 a, GF2 b)
{ GF2 x; add(x, a, b); return x; }
inline GF2 operator+(GF2 a, long b)
{ GF2 x; add(x, a, b); return x; }
inline GF2 operator+(long a, GF2 b)
{ GF2 x; add(x, a, b); return x; }
inline GF2 operator-(GF2 a, GF2 b)
{ GF2 x; sub(x, a, b); return x; }
inline GF2 operator-(GF2 a, long b)
{ GF2 x; sub(x, a, b); return x; }
inline GF2 operator-(long a, GF2 b)
{ GF2 x; sub(x, a, b); return x; }
inline GF2 operator-(GF2 a)
{ GF2 x; negate(x, a); return x; }
inline GF2& operator+=(GF2& x, GF2 b)
{ add(x, x, b); return x; }
inline GF2& operator+=(GF2& x, long b)
{ add(x, x, b); return x; }
inline GF2& operator-=(GF2& x, GF2 b)
{ sub(x, x, b); return x; }
inline GF2& operator-=(GF2& x, long b)
{ sub(x, x, b); return x; }
inline GF2& operator++(GF2& x) { add(x, x, 1); return x; }
inline void operator++(GF2& x, int) { add(x, x, 1); }
inline GF2& operator--(GF2& x) { sub(x, x, 1); return x; }
inline void operator--(GF2& x, int) { sub(x, x, 1); }
inline void mul(GF2& x, GF2 a, GF2 b)
{ x._GF2__rep = a._GF2__rep & b._GF2__rep; }
inline void mul(GF2& x, GF2 a, long b)
{ x._GF2__rep = a._GF2__rep & b; }
inline void mul(GF2& x, long a, GF2 b)
{ x._GF2__rep = a & b._GF2__rep; }
inline void sqr(GF2& x, GF2 a)
{ x = a; }
inline GF2 sqr(GF2 a)
{ return a; }
inline GF2 operator*(GF2 a, GF2 b)
{ GF2 x; mul(x, a, b); return x; }
inline GF2 operator*(GF2 a, long b)
{ GF2 x; mul(x, a, b); return x; }
inline GF2 operator*(long a, GF2 b)
{ GF2 x; mul(x, a, b); return x; }
inline GF2& operator*=(GF2& x, GF2 b)
{ mul(x, x, b); return x; }
inline GF2& operator*=(GF2& x, long b)
{ mul(x, x, b); return x; }
void div(GF2& x, GF2 a, GF2 b);
void div(GF2& x, long a, GF2 b);
void div(GF2& x, GF2 a, long b);
void inv(GF2& x, GF2 a);
inline GF2 inv(GF2 a)
{ GF2 x; inv(x, a); return x; }
inline GF2 operator/(GF2 a, GF2 b)
{ GF2 x; div(x, a, b); return x; }
inline GF2 operator/(GF2 a, long b)
{ GF2 x; div(x, a, b); return x; }
inline GF2 operator/(long a, GF2 b)
{ GF2 x; div(x, a, b); return x; }
inline GF2& operator/=(GF2& x, GF2 b)
{ div(x, x, b); return x; }
inline GF2& operator/=(GF2& x, long b)
{ div(x, x, b); return x; }
void power(GF2& x, GF2 a, long e);
inline GF2 power(GF2 a, long e)
{ GF2 x; power(x, a, e); return x; }
inline long IsZero(GF2 a)
{ return a._GF2__rep == 0; }
inline long IsOne(GF2 a)
{ return a._GF2__rep == 1; }
inline long operator==(GF2 a, GF2 b)
{ return a._GF2__rep == b._GF2__rep; }
inline long operator!=(GF2 a, GF2 b)
{ return !(a == b); }
inline long operator==(GF2 a, long b) { return a._GF2__rep == (b & 1); }
inline long operator==(long a, GF2 b) { return (a & 1) == b._GF2__rep; }
inline long operator!=(GF2 a, long b) { return !(a == b); }
inline long operator!=(long a, GF2 b) { return !(a == b); }
inline void random(GF2& x)
{ x._GF2__rep = RandomBnd(2); }
inline GF2 random_GF2()
{ GF2 x; random(x); return x; }
NTL_SNS ostream& operator<<(NTL_SNS ostream& s, GF2 a);
NTL_SNS istream& operator>>(NTL_SNS istream& s, GF2& x);
NTL_CLOSE_NNS
#endif
|