/usr/include/NTL/lzz_p.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 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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | #ifndef NTL_zz_p__H
#define NTL_zz_p__H
#include <NTL/ZZ.h>
#include <NTL/FFT.h>
NTL_OPEN_NNS
class zz_pInfoT {
private:
zz_pInfoT(); // disabled
zz_pInfoT(const zz_pInfoT&); // disabled
void operator=(const zz_pInfoT&); // disabled
public:
zz_pInfoT(long NewP, long maxroot);
zz_pInfoT(long Index);
~zz_pInfoT();
long ref_count;
long p;
double pinv;
long index; // index >= 0 means we are directly using
// an FFT prime
long PrimeCnt; // 0 for FFT prime; otherwise same as NumPrimes
// used for establishing crossover points
long NumPrimes;
long MaxRoot;
long MinusMModP; // -M mod p, M = product of primes
// the following arrays are indexed 0..NumPrimes-1
// q = FFTPrime[i]
long *CoeffModP; // coeff mod p
double *x; // u/q, where u = (M/q)^{-1} mod q
long *u; // u, as above
};
extern zz_pInfoT *zz_pInfo; // current modulus, initially null
class zz_pContext {
private:
zz_pInfoT *ptr;
public:
void save();
void restore() const;
zz_pContext() { ptr = 0; }
zz_pContext(long p, long maxroot=NTL_FFTMaxRoot);
zz_pContext(INIT_FFT_TYPE, long index);
zz_pContext(const zz_pContext&);
zz_pContext& operator=(const zz_pContext&);
~zz_pContext();
};
class zz_pBak {
private:
long MustRestore;
zz_pInfoT *ptr;
zz_pBak(const zz_pBak&); // disabled
void operator=(const zz_pBak&); // disabled
public:
void save();
void restore();
zz_pBak() { MustRestore = 0; ptr = 0; }
~zz_pBak();
};
#define NTL_zz_pRegister(x) zz_p x
class zz_p {
public:
long _zz_p__rep;
static void init(long NewP, long maxroot=NTL_FFTMaxRoot);
static void FFTInit(long index);
// ****** constructors and assignment
zz_p() { _zz_p__rep = 0; }
zz_p(const zz_p& a) : _zz_p__rep(a._zz_p__rep) { }
~zz_p() { }
zz_p& operator=(const zz_p& a) { _zz_p__rep = a._zz_p__rep; return *this; }
inline zz_p& operator=(long a);
// a loop-hole for direct access to _zz_p__rep
long& LoopHole() { return _zz_p__rep; }
static long modulus() { return zz_pInfo->p; }
static zz_p zero() { return zz_p(); }
static double ModulusInverse() { return zz_pInfo->pinv; }
static long PrimeCnt() { return zz_pInfo->PrimeCnt; }
static long storage() { return sizeof(long); }
zz_p(long a, INIT_LOOP_HOLE_TYPE) { _zz_p__rep = a; }
};
zz_p to_zz_p(long a);
void conv(zz_p& x, long a);
inline zz_p& zz_p::operator=(long a) { conv(*this, a); return *this; }
zz_p to_zz_p(const ZZ& a);
void conv(zz_p& x, const ZZ& a);
// read-only access to _zz_p__representation
inline long rep(zz_p a) { return a._zz_p__rep; }
inline void clear(zz_p& x)
// x = 0
{ x._zz_p__rep = 0; }
inline void set(zz_p& x)
// x = 1
{ x._zz_p__rep = 1; }
inline void swap(zz_p& x, zz_p& y)
// swap x and y
{ long t; t = x._zz_p__rep; x._zz_p__rep = y._zz_p__rep; y._zz_p__rep = t; }
// ****** addition
inline void add(zz_p& x, zz_p a, zz_p b)
// x = a + b
{ x._zz_p__rep = AddMod(a._zz_p__rep, b._zz_p__rep, zz_p::modulus()); }
inline void sub(zz_p& x, zz_p a, zz_p b)
// x = a - b
{ x._zz_p__rep = SubMod(a._zz_p__rep, b._zz_p__rep, zz_p::modulus()); }
inline void negate(zz_p& x, zz_p a)
// x = -a
{ x._zz_p__rep = SubMod(0, a._zz_p__rep, zz_p::modulus()); }
// scalar versions
inline void add(zz_p& x, zz_p a, long b) { add(x, a, to_zz_p(b)); }
inline void add(zz_p& x, long a, zz_p b) { add(x, to_zz_p(a), b); }
inline void sub(zz_p& x, zz_p a, long b) { sub(x, a, to_zz_p(b)); }
inline void sub(zz_p& x, long a, zz_p b) { sub(x, to_zz_p(a), b); }
inline zz_p operator+(zz_p a, zz_p b)
{ zz_p x; add(x, a, b); return x; }
inline zz_p operator+(zz_p a, long b)
{ zz_p x; add(x, a, b); return x; }
inline zz_p operator+(long a, zz_p b)
{ zz_p x; add(x, a, b); return x; }
inline zz_p operator-(zz_p a, zz_p b)
{ zz_p x; sub(x, a, b); return x; }
inline zz_p operator-(zz_p a, long b)
{ zz_p x; sub(x, a, b); return x; }
inline zz_p operator-(long a, zz_p b)
{ zz_p x; sub(x, a, b); return x; }
inline zz_p operator-(zz_p a)
{ zz_p x; negate(x, a); return x; }
inline zz_p& operator+=(zz_p& x, zz_p b)
{ add(x, x, b); return x; }
inline zz_p& operator+=(zz_p& x, long b)
{ add(x, x, b); return x; }
inline zz_p& operator-=(zz_p& x, zz_p b)
{ sub(x, x, b); return x; }
inline zz_p& operator-=(zz_p& x, long b)
{ sub(x, x, b); return x; }
inline zz_p& operator++(zz_p& x) { add(x, x, 1); return x; }
inline void operator++(zz_p& x, int) { add(x, x, 1); }
inline zz_p& operator--(zz_p& x) { sub(x, x, 1); return x; }
inline void operator--(zz_p& x, int) { sub(x, x, 1); }
// ****** multiplication
inline void mul(zz_p& x, zz_p a, zz_p b)
// x = a*b
{ x._zz_p__rep = MulMod(a._zz_p__rep, b._zz_p__rep, zz_p::modulus(), zz_p::ModulusInverse()); }
inline void mul(zz_p& x, zz_p a, long b) { mul(x, a, to_zz_p(b)); }
inline void mul(zz_p& x, long a, zz_p b) { mul(x, to_zz_p(a), b); }
inline zz_p operator*(zz_p a, zz_p b)
{ zz_p x; mul(x, a, b); return x; }
inline zz_p operator*(zz_p a, long b)
{ zz_p x; mul(x, a, b); return x; }
inline zz_p operator*(long a, zz_p b)
{ zz_p x; mul(x, a, b); return x; }
inline zz_p& operator*=(zz_p& x, zz_p b)
{ mul(x, x, b); return x; }
inline zz_p& operator*=(zz_p& x, long b)
{ mul(x, x, b); return x; }
inline void sqr(zz_p& x, zz_p a)
// x = a^2
{ x._zz_p__rep = MulMod(a._zz_p__rep, a._zz_p__rep, zz_p::modulus(), zz_p::ModulusInverse()); }
inline zz_p sqr(zz_p a)
{ zz_p x; sqr(x, a); return x; }
// ****** division
inline void div(zz_p& x, zz_p a, zz_p b)
// x = a/b
{ x._zz_p__rep = MulMod(a._zz_p__rep, InvMod(b._zz_p__rep, zz_p::modulus()), zz_p::modulus(),
zz_p::ModulusInverse()); }
inline void inv(zz_p& x, zz_p a)
// x = 1/a
{ x._zz_p__rep = InvMod(a._zz_p__rep, zz_p::modulus()); }
inline zz_p inv(zz_p a)
{ zz_p x; inv(x, a); return x; }
inline void div(zz_p& x, zz_p a, long b) { div(x, a, to_zz_p(b)); }
inline void div(zz_p& x, long a, zz_p b) { div(x, to_zz_p(a), b); }
inline zz_p operator/(zz_p a, zz_p b)
{ zz_p x; div(x, a, b); return x; }
inline zz_p operator/(zz_p a, long b)
{ zz_p x; div(x, a, b); return x; }
inline zz_p operator/(long a, zz_p b)
{ zz_p x; div(x, a, b); return x; }
inline zz_p& operator/=(zz_p& x, zz_p b)
{ div(x, x, b); return x; }
inline zz_p& operator/=(zz_p& x, long b)
{ div(x, x, b); return x; }
// ****** exponentiation
inline void power(zz_p& x, zz_p a, long e)
// x = a^e
{ x._zz_p__rep = PowerMod(a._zz_p__rep, e, zz_p::modulus()); }
inline zz_p power(zz_p a, long e)
{ zz_p x; power(x, a, e); return x; }
// ****** comparison
inline long IsZero(zz_p a)
{ return a._zz_p__rep == 0; }
inline long IsOne(zz_p a)
{ return a._zz_p__rep == 1; }
inline long operator==(zz_p a, zz_p b)
{ return a._zz_p__rep == b._zz_p__rep; }
inline long operator!=(zz_p a, zz_p b)
{ return !(a == b); }
inline long operator==(zz_p a, long b) { return a == to_zz_p(b); }
inline long operator==(long a, zz_p b) { return to_zz_p(a) == b; }
inline long operator!=(zz_p a, long b) { return !(a == b); }
inline long operator!=(long a, zz_p b) { return !(a == b); }
// ****** random numbers
inline void random(zz_p& x)
// x = random element in zz_p
{ x._zz_p__rep = RandomBnd(zz_p::modulus()); }
inline zz_p random_zz_p()
{ zz_p x; random(x); return x; }
// ****** input/output
NTL_SNS ostream& operator<<(NTL_SNS ostream& s, zz_p a);
NTL_SNS istream& operator>>(NTL_SNS istream& s, zz_p& x);
NTL_CLOSE_NNS
#endif
|