This file is indexed.

/usr/share/doc/libntl-dev/NTL/ZZ_pE.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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/**************************************************************************\

MODULE: ZZ_pE

SUMMARY:

The class ZZ_pE is used to represent polynomials in Z_p[X] modulo a
polynomial P.  The modulus P may be any polynomial with deg(P) > 0,
not necessarily irreducible.  The modulus p defining Z_p need
not be prime either.

Objects of the class ZZ_pE are represented as a ZZ_pX of degree < deg(P).

An executing program maintains a "current modulus", which is set to P
using ZZ_pE::init(P).  The current modulus for ZZ_pE (as well as for ZZ_p)
*must* be initialized before an operations on ZZ_pE's are performed.

The modulus may be changed, and a mechanism is provided for saving and
restoring a modulus (see classes ZZ_pEPush and ZZ_pEContext below).


\**************************************************************************/

#include <NTL/ZZ_pX.h>

class ZZ_pE {
public:
   
   ZZ_pE(); // initial value 0

   ZZ_pE(const ZZ_pE& a); // copy constructor
   explicit ZZ_pE(const ZZ_p& a); // promotion
   explicit ZZ_pE(long a); // promotion
   
   ZZ_pE& operator=(const ZZ_pE& a); // assignment
   ZZ_pE& operator=(const ZZ_p& a); // assignment
   ZZ_pE& operator=(long a); // assignment
   
   ~ZZ_pE(); // destructor

   void init(const ZZ_pX& P);
   // ZZ_pE::init(P) initializes the current modulus to P;
   // required: deg(P) >= 1.
   
   static const ZZ_pXModulus& modulus();
   // ZZ_pE::modulus() yields read-only reference to the current modulus 

   static long degree();
   // ZZ_pE::degree() returns deg(P)


   // typedefs to aid generic programming
   typedef ZZ_pX rep_type;
   typedef ZZ_pEContext context_type;
   typedef ZZ_pEBak bak_type;
   typedef ZZ_pEPush push_type;
   typedef ZZ_pEX poly_type;

};


const ZZ_pX& rep(const ZZ_pE& a); // read-only access to representation of a



/**************************************************************************\

                                  Comparison

\**************************************************************************/

long operator==(const ZZ_pE& a, const ZZ_pE& b);
long operator!=(const ZZ_pE& a, const ZZ_pE& b);

long IsZero(const ZZ_pE& a);  // test for 0
long IsOne(const ZZ_pE& a);  // test for 1

// PROMOTIONS: ==, != promote {long, ZZ_p} to ZZ_pE on (a, b).


/**************************************************************************\

                                    Addition 

\**************************************************************************/

// operator notation:

ZZ_pE operator+(const ZZ_pE& a, const ZZ_pE& b);

ZZ_pE operator-(const ZZ_pE& a, const ZZ_pE& b);
ZZ_pE operator-(const ZZ_pE& a);

ZZ_pE& operator+=(ZZ_pE& x, const ZZ_pE& a);
ZZ_pE& operator+=(ZZ_pE& x, const ZZ_p& a);
ZZ_pE& operator+=(ZZ_pE& x, long a);

ZZ_pE& operator++(ZZ_pE& x); // prefix
void operator++(ZZ_pE& x, int); // postfix

ZZ_pE& operator-=(ZZ_pE& x, const ZZ_pE& a);
ZZ_pE& operator-=(ZZ_pE& x, const ZZ_p& a);
ZZ_pE& operator-=(ZZ_pE& x, long a);

ZZ_pE& operator--(ZZ_pE& x); // prefix
void operator--(ZZ_pE& x, int); // postfix

// procedural versions:

void add(ZZ_pE& x, const ZZ_pE& a, const ZZ_pE& b); // x = a + b
void sub(ZZ_pE& x, const ZZ_pE& a, const ZZ_pE& b); // x = a - b 
void negate(ZZ_pE& x, const ZZ_pE& a); // x = - a 

// PROMOTIONS: +, -, add, sub promote {long, ZZ_p} to ZZ_pE on (a, b).


/**************************************************************************\

                                  Multiplication 

\**************************************************************************/


// operator notation:

ZZ_pE operator*(const ZZ_pE& a, const ZZ_pE& b);

ZZ_pE& operator*=(ZZ_pE& x, const ZZ_pE& a);
ZZ_pE& operator*=(ZZ_pE& x, const ZZ_p& a);
ZZ_pE& operator*=(ZZ_pE& x, long a);

// procedural versions:


void mul(ZZ_pE& x, const ZZ_pE& a, const ZZ_pE& b); // x = a * b

void sqr(ZZ_pE& x, const ZZ_pE& a); // x = a^2
ZZ_pE sqr(const ZZ_pE& a); 

// PROMOTIONS: *, mul promote {long, ZZ_p} to ZZ_pE on (a, b).



/**************************************************************************\

                                     Division

\**************************************************************************/


// operator notation:

ZZ_pE operator/(const ZZ_pE& a, const ZZ_pE& b);

ZZ_pE& operator/=(ZZ_pE& x, const ZZ_pE& a);
ZZ_pE& operator/=(ZZ_pE& x, const ZZ_p& a);
ZZ_pE& operator/=(ZZ_pE& x, long a);


// procedural versions:

void div(ZZ_pE& x, const ZZ_pE& a, const ZZ_pE& b);
// x = a/b.  If b is not invertible, an error is raised.

void inv(ZZ_pE& x, const ZZ_pE& a);
ZZ_pE inv(const ZZ_pE& a);
// x = 1/a

PROMOTIONS: /, div promote {long, ZZ_p} to ZZ_pE on (a, b).


/**************************************************************************\

                                  Exponentiation

\**************************************************************************/



void power(ZZ_pE& x, const ZZ_pE& a, const ZZ& e); 
ZZ_pE power(const ZZ_pE& a, const ZZ& e);

void power(ZZ_pE& x, const ZZ_pE& a, long e); 
ZZ_pE power(const ZZ_pE& a, long e);

// x = a^e (e may be negative)



/**************************************************************************\

                               Random Elements

\**************************************************************************/


void random(ZZ_pE& x);
ZZ_pE random_ZZ_pE();
// x = random element in ZZ_pE.

/**************************************************************************\

                               Norms and Traces

\**************************************************************************/



void trace(ZZ_p& x, const ZZ_pE& a);  // x = trace of a
ZZ_p trace(const ZZ_pE& a);

void norm(ZZ_p& x, const ZZ_pE& a);   // x = norm of a
ZZ_p norm(const ZZ_pE& a);



/**************************************************************************\

                                Input/Output

\**************************************************************************/


ostream& operator<<(ostream& s, const ZZ_pE& a);

istream& operator>>(istream& s, ZZ_pE& x);
// a ZZ_pX is read and reduced mod p


/**************************************************************************\

                       Modulus Switching 

A class ZZ_pEPush is provided for "backing up" the current modulus
and installing a new one.

Here is what you do to save the current modulus, temporarily
set it to P, and automatically restore it:

   { 
      ZZ_pEPush push(P); 

      ...

   }

The constructor for push will save the current modulus, and install P as the
current modulus.  The destructor for push will restore the old modulus when the
scope enclosing it exits.  This is the so-called RAII (resource acquisition is
initialization) paradigm.

You could also do the following:

   {
      ZZ_pEPush push; // just backup current modulus

        ...

      ZZ_pE::init(P1); // install P1 

        ...

      ZZ_pE::init(P2); // install P2

      // reinstall original modulus as close of scope
   }

      
The ZZ_pEPush interface is good for implementing simple stack-like
modulus "context switching".  For more general context switching,
see ZZ_pEContext below.  There is also an older ZZ_pEBak class
that may also be useful.

..........................................................................

It is critical that ZZ_pE objects created under one ZZ_pE modulus are not used in
any non-trivial way "out of context", i.e., under a different (or undefined)
ZZ_pE modulus.  However, for ease-of-use, some operations may be safely
performed out of context.  These safe operations include: the default and copy
constructor, the destructor, and the assignment operator.  In addition is is
generally safe to read any ZZ_pE object out of context (i.e., printing it out, or
fetching its underlying representive using the rep() function).

Any unsafe uses out of context are not in general checked, and may 
lead to unpredictable behavior.


\**************************************************************************/


// A convenient interface for common cases

class ZZ_pEPush {

public:
ZZ_pEPush();  // backup current modulus
explicit ZZ_pEPush(const ZZ_pX& P); 
explicit ZZ_pEPush(const ZZ_pEContext& context); 
  // backup current modulus and install the given one

private:
ZZ_pEPush(const ZZ_pEPush&); // disabled
void operator=(const ZZ_pEPush&); // disabled

};



// more general context switching:
// A ZZ_pEContext object has a modulus Q (possibly "null"),

class ZZ_pEContext {


public:

ZZ_pEContext(); // Q = "null"
explicit ZZ_pEContext(const ZZ_pX& P); // Q = P

void save(); // Q = CurrentModulus
void restore() const; // CurrentModulus = Q

ZZ_pEContext(const ZZ_pEContext&);  // copy
ZZ_pEContext& operator=(const ZZ_pEContext&); // assignment
~ZZ_pEContext(); // destructor


};


// An older interface:
// To describe this logic, think of a ZZ_pEBak object
// of having two components: a modulus Q (possibly "null") and 
// an "auto-restore bit" b.


class ZZ_pEBak {
public:


   ZZ_pEBak();  // Q = "null", b = 0

   ~ZZ_pEBak();  // if (b) CurrentModulus = Q

   void save();  // Q = CurrentModulus, b = 1 
   void restore();  // CurrentModulus = Q, b = 0


private:
   ZZ_pEBak(const ZZ_pEBak&);  // copy disabled
   void operator=(const ZZ_pEBak&);  // assignment disabled
};






/**************************************************************************\

                               Miscellany

\**************************************************************************/

void clear(ZZ_pE& x); // x = 0
void set(ZZ_pE& x); // x = 1

static const ZZ_pE& ZZ_pE::zero();
// ZZ_pE::zero() yields a read-only reference to zero

void ZZ_pE::swap(ZZ_pE& x);
void swap(ZZ_pE& x, ZZ_pE& y);
// swap (done by "pointer swapping", if possible).

static ZZ& ZZ_pE::cardinality();
// yields the cardinality, i.e., p^{ZZ_pE::degree()}

ZZ_pE::ZZ_pE(INIT_NO_ALLOC_TYPE);
// special constructor: invoke as ZZ_pE x(INIT_NO_ALLOC);
// initializes x to 0, but allocates no space (this is now the default)

ZZ_pE::ZZ_pE(INIT_ALLOC_TYPE);
// special constructor: invoke as ZZ_pE x(INIT_ALLOC);
// initializes x to 0, but allocates space

ZZ_pE::allocate();
// useful in conjunction with the INIT_NO_ALLLOC constructor:
// x.allocate() will pre-allocate space for x, using the
// current modulus