This file is indexed.

/usr/include/linbox/field/NTL/ntl-ZZ_pE.h is in liblinbox-dev 1.3.2-1.1build2.

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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/* Copyright (C) LinBox
 *
 *
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

/*! @file field/NTL/ntl-ZZ_pE.h
 * @ingroup field
 * @ingroup NTL
 * @brief NO DOC
 */

#ifndef __LINBOX_field_ntl_zz_pe_H
#define __LINBOX_field_ntl_zz_pe_H

#ifndef __LINBOX_HAVE_NTL
#error "you need NTL here"
#endif

#include <time.h>
#include "linbox/linbox-config.h"
#include "linbox/util/debug.h"
#include <NTL/ZZ_pXFactoring.h>
#include <NTL/ZZ_pE.h>
#include <NTL/ZZ.h>

#include "linbox/field/unparametric.h"
#include "linbox/randiter/unparametric.h"
#include "linbox/field/field-traits.h"

#ifdef __LINBOX_XMLENABLED

#include "linbox/util/xml/linbox-reader.h"
#include "linbox/util/xml/linbox-writer.h"

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

#endif //__LINBOX_XMLENABLED



#include "linbox/integer.h"

namespace Givaro
{

	template<>
	NTL::ZZ_pE& Caster(NTL::ZZ_pE &x, const Integer &y)
	{
		x=NTL::to_ZZ_pE(static_cast<long>(y));
		return x;
	}
	template<>
	NTL::ZZ_pE& Caster(NTL::ZZ_pE &x, const double &y)
	{
		x=NTL::to_ZZ_pE(static_cast<long>(y));
		return x;
	}

	// Rich Seagraves, 7-15-03
	// On the orders of Dr Saunders, I'm re-writing init & convert so that
	// they convert a ZZpE into a padic number, ie a0 + a1x + a2x^2 +... ->
	// a0 + a1*p + a2*p^2 + ...
	//

	Integer& Caster(Integer& c, const NTL::ZZ_pE& e)
	{
		NTL::ZZ_pX poly = rep(e);
		//Integer base = _p;
		Integer base = static_cast<Integer>(to_long(NTL::ZZ_p::modulus()));
		long i;

		c = 0;
		for(i = deg(poly); i >= 0; --i) {
			c *= base;
			c +=  NTL::to_long(rep(coeff(poly, i)));
		}

		return c;
	}
} // namespace Givaro

// Namespace in which all LinBox library code resides
namespace LinBox
{

	class NTL_ZZ_pE_Initialiser {
	public :
		NTL_ZZ_pE_Initialiser( const Integer & p, size_t k ) {
			// linbox_check(e == 1);
			// if ( q > 0 )
			// NTL::ZZ_p::init(NTL::to_ZZ((std::string(q)).data())); // it's an error if q not prime, e not 1
			NTL::ZZ_p::init(NTL::to_ZZ(std::string(p).data()));
			NTL::ZZ_pX irredPoly = NTL::BuildIrred_ZZ_pX ((long) k);
			NTL::ZZ_pE::init(irredPoly);

		}

		// template <class ElementInt>
		// NTL_ZZ_pE_Initialiser(const ElementInt& d) {
			// NTL::ZZ_p::init (NTL::to_ZZ(d));
		// }

		// NTL_ZZ_pE_Initialiser (const NTL::ZZ& d) {
			// NTL::ZZ_p::init(d);
		// }

	};



	/**
	 * @brief Wrapper of ZZ_pE from NTL
	 * Define a parameterized class to handle easily UnparametricField<NTL::ZZ_pE> field
	 */
	class NTL_ZZ_pE : public NTL_ZZ_pE_Initialiser, public UnparametricOperations<NTL::ZZ_pE> {
	public:
		typedef NTL::ZZ_pE Element ;
		typedef FFPACK::UnparametricOperations<Element> Father_t ;

		const Element zero,one,mOne ;


		NTL_ZZ_pE (const integer &p, const integer &k) :
			NTL_ZZ_pE_Initialiser(p,k),Father_t ()
			,zero( NTL::to_ZZ_pE(0)),one( NTL::to_ZZ_pE(1)),mOne(-one)


		{

				}


	bool isZero (const Element& a) const
	{
		return NTL::IsZero(a);
	}


	bool isOne (const Element& a) const
	{
		return NTL::IsOne(a);
	}



	integer& characteristic (integer &c) const
	{
		return c=static_cast<integer>(to_long(NTL::ZZ_p::modulus()));
		//NTL::ZZ_p::modulus();
	}


	integer& cardinality(integer& c) const
	{
		c=static_cast<integer>(to_long(NTL::ZZ_p::modulus()));
		c=pow(c,Element::degree());
		return c;
	}

	Element& inv(Element& x, const Element& y) const
	{
		x=NTL::to_ZZ_pE(1)/y;
		return x;
	}

	Element& invin(Element& x) const
	{
		x=NTL::to_ZZ_pE(1)/x;
		return x;
	}


	std::istream& read(std::istream& is, Element& x) const
	{
		long tmp;
		is>>tmp;
		x=NTL::to_ZZ_pE(tmp);
		return is;
	}



#ifdef __LINBOX_XMLENABLED


	bool toTag(LinBox::Writer &W) const
	{
		std::string s;
		NTL::ZZ_pX poly = Element::modulus();
		long i;

		W.setTagName("field");
		W.setAttribute("implDetail", "ntl-ZZpE");
		W.setAttribute("cardinality", LinBox::Writer::numToString(s, _card));

		W.addTagChild();
		W.setTagName("finite");

		W.addTagChild();
		W.setTagName("characteristic");
		W.addNum(_p);
		W.upToParent();

		W.addTagChild();
		W.setTagName("extension");
		W.addNum(deg(poly) + 1);
		W.upToParent();

		W.addTagChild();
		W.setTagName("polynomial");

		for(i = 0; i <= deg(poly); ++i) {
			W.addNum(coeff(poly, i));
		}
		W.upToParent();
		W.upToParent();
		W.upToParent();

		return true;
	}


	std::ostream &write(std::ostream &os) const
	{
		LinBox::Writer W;
		if( toTag(W) )
			W.write(os);

		return os;
	}


	// Elemnt Reading & writing functions
	// BIG NOTE:  It was decided that for extension fields, the elements
	// would be represented using a single number that has the following
	// property:  for an element e in ZZp[x], with e = a0 + a1x + a2x^2 + ...,
	// represent e as "<cn>n</cn>" where n = a0 + a1 * p + a2 * p^2 + ...
	//


	bool toTag(LinBox::Writer &W, const Element &e) const
	{
		NTL::ZZ_pX poly = rep(e);
		NTL::ZZ accum, base = NTL::ZZ_p::modulus();
		long i;
		std::string s;

		accum = 0;
		for(i = deg(poly); i >= 0; --i) {
			accum *= base;
			accum += rep(coeff(poly, i));
		}


		W.setTagName("cn");
		W.addDataChild(LinBox::Writer::numToString(s, accum));

		return true;
	}


	std::ostream &write(std::ostream &os, const Element &e) const
	{

		LinBox::Writer W;
		if( toTag(W, e))
			W.write(os);

		return os;
	}




	bool fromTag(LinBox::Reader &R, Element &e) const
	{
		NTL::ZZ total, base = NTL::ZZ_p::modulus(), rem;
		std::stringstream ss;

		if(!R.expectTagName("cn") || !R.expectChildTextNum(total))
			return false;

		ss << "[";
		while(total > 0) {
			rem = total % base;
			total /= base;
			ss << rem;
			if(total > 0) ss << " ";
		}

		ss << "]";

		ss >> e; // use the extraction stream operator

		return true;
	}


	std::istream &read(std::istream &is, Element &e) const
	{
		LinBox::Reader R(is);
		if( !fromTag(R, e)) {
			is.setstate(std::istream::failbit);
			if(!R.initalized()) {
				is.setstate(std::istream::badbit);
			}
		}

		return is;
	}


#endif


	}; // end of class NTL_ZZ_pE






	template <class Ring>
	struct ClassifyRing;

	template<>
	struct ClassifyRing<UnparametricRandIter<NTL::ZZ_pE> > {
		typedef RingCategories::ModularTag categoryTag;
	};



}

namespace LinBox
{


	template<>
	class UnparametricRandIter<NTL::ZZ_pE> {
	public:
		typedef NTL::ZZ_pE Element;
		UnparametricRandIter<NTL::ZZ_pE>(const NTL_ZZ_pE & F ,
						 const integer& size =0,
						 const integer& seed =0
						) :
			_size(size), _seed(seed)
		{
			if(_seed == 0)
				NTL::SetSeed(NTL::to_ZZ(time(0)));
			else
				NTL::SetSeed( NTL::to_ZZ(static_cast<long>(seed)) );
		}

#ifdef __LINBOX_XMLENABLED
		UnparametricRandIter<NTL::ZZ_pE>(LinBox::Reader &R)
		{
			if(!R.expectTagName("randiter")) return;
			if(!R.expectAttributeNum("seed", _seed) || !R.expectAttributeNum("size", _size)) return;

			if(_seed == 0) _seed = time(NULL);

			NTL::SetSeed(NTL::to_ZZ(_seed));
		}
#endif


		UnparametricRandIter<NTL::ZZ_pE>(const UnparametricRandIter<NTL::ZZ_pE>& R) :
			_size(R._size), _seed(R._seed)

		{
			if(_seed == 0)
				NTL::SetSeed(NTL::to_ZZ(time(0)));
			else
				NTL::SetSeed(NTL::to_ZZ( static_cast<long>(_seed)) );
		}

		NTL::ZZ_pE& random (NTL::ZZ_pE& x) const
		{
			NTL::random(x);
			return x;
		}

	protected:
		size_t _size;
		size_t _seed;
	};
}
#endif //__LINBOX_field_ntl_zz_pe_H

// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End: