This file is indexed.

/usr/include/linbox/field/Givaro/givaro-zpz.h is in liblinbox-dev 1.3.2-1.1.

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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
/* linbox/field/givaro-zpz.h
 * Copyright (C) 2002 Pascal Giorgi
 *
 * Written by Pascal Giorgi <pascal.giorgi@ens-lyon.fr>
 *
 * ------------------------------------
 *
 *
 * ========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========
 *.
 */

/* WARNING this wrapper works only with an improved version of Givaro.
 * This version of givaro won't be available for public yet.
 * But it is available on my web page.
 * You can send me a mail to get it or for others details.
 */

#ifndef __LINBOX_field_givaro_zpz_H
#define __LINBOX_field_givaro_zpz_H


#include "linbox/linbox-config.h"
#include "linbox/integer.h"
#include "linbox/field/field-interface.h"
#include "linbox/util/debug.h"
#include "linbox/vector/vector-domain.h"
//-------------------------------------
// Files of Givaro library
#include <givaro/givzpz.h>
#include <givaro/giv_randiter.h>
#include "linbox/field/field-traits.h"

//--------------------------------------

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

	/*  This wrappers allows to use three sorts of givaro fields :
	 *  Elements represent by a 32 bits integer
	 *  Elements represent by a 16 bits integer
	 *  Elements represent in Zech log representation by a 16 bits integer
	 *
	 *  To use this fields with the wrapper below just replace the template
	 *  parameter by the Tag appropriated.
	 *  "Givaro::Std16"  for 16 bits integer
	 *  "Givaro::Std32"  for 32 bits integer
	 *  "Givaro::Log16"  for Zech log representation in 16 bits
	 */
	template<class Field>
	class DotProductDomain;
	template<class Field>
	class FieldAXPY;

	template <class Ring>
	struct ClassifyRing;

	template <class TAG>
	class GivaroZpz;

	template<class Tag>
	struct ClassifyRing<GivaroZpz<Tag> > {
		typedef RingCategories::ModularTag categoryTag;
	};

	/** \brief wrapper of Givaro's ZpzDom.
	  \ingroup field

	 *  Most methods are inherited from Givaro::ZpzDom< Givaro::Std16>, Givaro::ZpzDom< Givaro::Std32>
	 *  and Givaro::ZpzDom<log16> classes of Givaro.
	 *  These classes allow to construct only finite field with a prime modulus.
	 */
	template <class TAG>
	class GivaroZpz : public Givaro::ZpzDom<TAG>, public FieldInterface {

	private:

		/*		friend class DotProductDomain<GivaroZpz<TAG> > ;
				friend class FieldAXPY<GivaroZpz<TAG> >; */

	public:

		//typedef integer Integer;

		/** Element type.
		 *  This type is inherited from the Givaro class Givaro::ZpzDom<TAG>
		 */
		typedef typename Givaro::ZpzDom<TAG>::Rep Element;
		// Element zero,one,mOne;
		typedef Givaro::ZpzDom<TAG> Father_t ;
		typedef GivaroZpz<TAG>      Self_t ;
		using  Father_t::one ;
		using  Father_t::zero ;
		using  Father_t::mOne ;

		/** RandIter type
		 *  This type is inherited from the Givaro class Givaro::ZpzDom<TAG>
		 */
		typedef Givaro::GIV_randIter< Givaro::ZpzDom<TAG>, integer > RandIter;

		/** Constructor from an integer
		 *  this constructor use the Givaro::ZpzDom<TAG> constructor
		 */
		GivaroZpz (const integer &p) :
		 Givaro::ZpzDom<TAG> (static_cast<typename Givaro::ZpzDom<TAG>::Residu_t> (p))
		{}


		/** Constructor from an integer (takes degree of extension as 2nd parameter, must be 1)
		 *  this constructor use the Givaro::ZpzDom<TAG> constructor
		 */
		GivaroZpz (const integer &p, const integer& k) :
		 Givaro::ZpzDom<TAG> (static_cast<typename Givaro::ZpzDom<TAG>::Residu_t> (p))
		{

			if (k!=1)
				throw PreconditionFailed(__func__,__FILE__,__LINE__,"exponent must be 1");
		}

		/** Copy constructor.
		 * This copy constructor use the Givaro::ZpzDom<TAG> copy constructor
		 */
		GivaroZpz (const GivaroZpz<TAG>& F) :
		 Givaro::ZpzDom<TAG> (F)
		{}


#if 0
		// Rich Seagraves 7-16-2003
		// As is, this operator is an infinite loop
		// By not providing an operator= in GivaroZpz,
		// the operator= in the base class ( Givaro::ZpzDom<TAG>) is called
		// automatically by the rules of C++, which I'm guessing is
		// the "Right Thing" for this operator
		//
		/** Operator =
		*/
		/*
		   GivaroZpz<TAG>& operator= (const GivaroZpz<TAG>& F)
		   {
		   return (*this)=F;
		   }
		   */
#endif

		/** Characteristic.
		 * Return integer representing characteristic of the domain.
		 * @return integer representing characteristic of the domain.
		 */
		integer &characteristic (integer &c) const
		{
			return c = integer ( Givaro::ZpzDom<TAG>::size ());
		}
		unsigned long &characteristic (unsigned long &c) const
		{
			return c = (unsigned long) ( Givaro::ZpzDom<TAG>::size ());
		}

		long characteristic() const
		{
			return static_cast<int>( Givaro::ZpzDom<TAG>::size());
		}

		/** Cardinality.
		 * Return integer representing cardinality of the domain.
		 * @return integer representing cardinality of the domain
		 */
		integer &cardinality (integer &c) const
		{
			return c = integer ( Givaro::ZpzDom<TAG>::size ());
		}

		integer cardinality () const
		{
			return integer ( Givaro::ZpzDom<TAG>::size ());
		}

		/** Conversion of field base element to an integer.
		 * This function assumes the output field base element x has already been
		 * constructed, but that it is not already initialized.
		 * @return reference to an integer.
		 * @param x integer to contain output (reference returned).
		 * @param y constant field base element.
		 */
		integer &convert (integer &x, const Element &y) const
		{
			return x = integer (y);
		}

		double &convert (double& x, const Element& y) const
		{
			return x = static_cast<double>(y);
		}

		template<class Type>
		Type &convert (Type& x, const Element& y) const
		{
			return x = static_cast<Type>(y);
		}


		/** Initialization of field base element from an integer.
		 * Behaves like C++ allocator construct.
		 * This function assumes the output field base element x has already been
		 * constructed, but that it is not already initialized.
		 * @return reference to field base element.
		 * @param x field base element to contain output (reference returned).
		 * @param y integer.
		 */
		Element &init (Element &x , const integer &y = 0) const
		{
			//
			//	AU 28/03/07 no cast to long allows to use Givaro::ZpzDom<integer>
			//
			//Givaro::ZpzDom<TAG>::init (x, (long) (y% integer(this->_p)));
			Givaro::ZpzDom<TAG>::init (x, (y% integer(this->_p)));
			return x;
		}

		Element &init (Element &x , const long &y ) const
		{
			return Givaro::ZpzDom<TAG>::init (x, y ) ;

		}
		Element &init (Element &x , const int &y ) const
		{
			return Givaro::ZpzDom<TAG>::init (x, y ) ;

		}

		Element &init (Element &x , const unsigned&y ) const
		{
			return Givaro::ZpzDom<TAG>::init (x, y ) ;

		}

		Element &init (Element &x , const unsigned long &y ) const
		{
			return Givaro::ZpzDom<TAG>::init (x, y ) ;

		}

		Element &init (Element &x , const double &y ) const
		{
			double z = fmod(y, (double) this->_p);
			if (z < 0) z += (double) this->_p;
			z += 0.5;
			return x = static_cast<Element>(z); //rounds towards 0
		}

		static uint64_t getMaxModulus();

	}; // class GivaroZpz<TAG>


	template <> uint64_t GivaroZpz< Givaro::Std32>::getMaxModulus() { return 46339; } // 2^15.5-1
	template <> uint64_t GivaroZpz< Givaro::Std64>::getMaxModulus() { return 3037000499ULL; } // 2^15.5-1
	template <> uint64_t GivaroZpz< Givaro::Unsigned32>::getMaxModulus() { return 65535; } // 2^16-1
	template <> uint64_t GivaroZpz< Givaro::Std16>::getMaxModulus() { return 255; }   // 2^8-1
	template <> uint64_t GivaroZpz< Givaro::Log16>::getMaxModulus() { return 32767; } // 2^15 - 1

	/** Specialisation of the convert function for the zech log representation
	 *	of givaro-zpz (GivaroZpz< Givaro::Log16>.
	 *  this function translates the internal representation to the real
	 *	value of the element.
	 *	This can have no sense but can be usefull
	 *  NB : the init function for this specialisation does the same thing.
	 *  the function transaltes the values to her internal representation.
	 */
	template <> integer& GivaroZpz< Givaro::Log16>::convert(integer& x, const Element& y) const
	{
		if (y>=this->_p) return x = 0;
		int tmp = _tab_rep2value[y];
		return x = integer (tmp);
	}

	template <> double& GivaroZpz< Givaro::Log16>::convert(double& x, const Element& y) const
	{
		if (y>=this->_p) return x = 0.0;
		int tmp = _tab_rep2value[y];
		return x = (double) tmp;
	}

	template <> GivaroZpz< Givaro::Log16>::Element& GivaroZpz< Givaro::Log16>::init(GivaroZpz< Givaro::Log16>::Element& x, const double& y) const
	{
		double z = fmod(y, (double) this->_p);
		if (z < 0) z += this->_p;
		z += 0.5;
		return x = _tab_value2rep[static_cast<long>(z)]; //rounds towards 0
	}

	template <> GivaroZpz< Givaro::Log16>::Element& GivaroZpz< Givaro::Log16>::init(GivaroZpz< Givaro::Log16>::Element& x, const integer& y) const
	{
		int tmp =(int) (y % (integer)this->_p);
		if (tmp < 0 ) tmp += this->_p;
		return x = _tab_value2rep[tmp];
	}

	/* Specialization of FieldAXPY for GivaroZpz< Givaro::Std32> Field */

	template <>
	class FieldAXPY<GivaroZpz< Givaro::Std32> > {
	public:

		typedef GivaroZpz< Givaro::Std32>::Element Element;
		typedef GivaroZpz< Givaro::Std32> Field;

		FieldAXPY (const Field &F) :
			_field (F) , Corr(uint64_t(-1) % (uint64_t)F.characteristic() +1)
		{ _y = 0; }
		FieldAXPY (const FieldAXPY &faxpy) :
			_field (faxpy._field), _y (0) , Corr(faxpy.Corr)
		{}

		FieldAXPY<GivaroZpz< Givaro::Std32> > &operator = (const FieldAXPY &faxpy)
		{ _field = faxpy._field; _y = faxpy._y; Corr = faxpy.Corr; return *this; }

		inline uint64_t& mulacc (const Element &a, const Element &x)
		{
			uint64_t t = (uint64_t) a * (uint64_t) x;
			_y += t;
			if (_y < t)
				return _y += Corr;
			else
				return _y;
		}

		inline uint64_t& accumulate (const Element &t)
		{
			_y += t;
			if (_y < (uint64_t)t)
				return _y += Corr;
			else
				return _y;
		}

		inline Element &get (Element &y) {
			_y %= (uint64_t) _field.characteristic();
			if ((int64_t) _y < 0) _y += _field.characteristic();
			y = (uint32_t) _y;
			return y;
		}

		inline FieldAXPY &assign (const Element y)
		{ _y = y; return *this; }

		inline void reset() {
			_y = 0;
		}

	private:

		Field _field;
		uint64_t _y;
		uint64_t Corr;
	};


	/* Specialization of FieldAXPY for GivaroZpz< Givaro::Std32> Field */

	template <>
	class FieldAXPY<GivaroZpz< Givaro::Std16> > {
	public:

		typedef GivaroZpz< Givaro::Std16>::Element Element;
		typedef GivaroZpz< Givaro::Std16> Field;

		FieldAXPY (const Field &F) :
			_field (F) , Corr(uint32_t(-1) % (uint32_t)F.characteristic() +1)
		{
			_y = 0;
		}
		FieldAXPY (const FieldAXPY &faxpy) :
			_field (faxpy._field), _y (0) , Corr(faxpy.Corr)
		{}

		FieldAXPY<GivaroZpz< Givaro::Std16> > &operator = (const FieldAXPY &faxpy)
		{
			_field = faxpy._field;
			_y = faxpy._y;
			Corr = faxpy.Corr;
			return *this;
		}

		inline uint32_t& mulacc (const Element &a, const Element &x)
		{
			uint32_t t = (uint32_t) a * (uint32_t) x;
			_y += t;

			if (_y < t)
				return _y += Corr;
			else
				return _y;
		}

		inline uint32_t& accumulate (const Element &t)
		{
			_y += t;

			if (_y < (uint32_t)t)
				return _y += Corr;
			else
				return _y;
		}

		inline Element &get (Element &y)
		{
			_y %= (uint32_t) _field.characteristic();
			if ((int32_t) _y < 0)
				_y += (Element) _field.characteristic();
			y = (uint16_t) _y;
			return y;
		}

		inline FieldAXPY &assign (const Element y)
		{
			_y = y;
			return *this;
		}

		inline void reset()
		{
			_y = 0;
		}

	private:

		Field _field;
		uint32_t _y;
		uint32_t Corr;
	};

	// Specialization of DotProductDomain for GivaroZpz< Givaro::Std32> field

	template <>
	class DotProductDomain<GivaroZpz< Givaro::Std32> > :  private virtual VectorDomainBase<GivaroZpz< Givaro::Std32> > {

	public:

		typedef GivaroZpz< Givaro::Std32>::Element Element;

		DotProductDomain (const GivaroZpz< Givaro::Std32> &F) :
			VectorDomainBase<GivaroZpz< Givaro::Std32> > (F) ,
			Corr(uint64_t(-1) % (uint64_t)F.characteristic() +1),
			Max(uint64_t(-1))
		{}

	protected:
		template <class Vector1, class Vector2>
		inline Element &dotSpecializedDD (Element &res, const Vector1 &v1, const Vector2 &v2) const;

		template <class Vector1, class Vector2>
		inline Element &dotSpecializedDSP (Element &res, const Vector1 &v1, const Vector2 &v2) const;

	private:
		uint64_t Corr;
		uint64_t Max;
	};

	// Specialization of DotProductDomain for GivaroZpz< Givaro::Std16> field

	template <>
	class DotProductDomain<GivaroZpz< Givaro::Std16> > :  private virtual VectorDomainBase<GivaroZpz< Givaro::Std16> > {

	public:

		typedef GivaroZpz< Givaro::Std16>::Element Element;

		DotProductDomain (const GivaroZpz< Givaro::Std16> &F) :
			VectorDomainBase<GivaroZpz< Givaro::Std16> > (F) ,
			Corr(uint32_t(-1) % (uint32_t)F.characteristic() +1),
			Max(uint32_t(-1))
		{}

	protected:
		template <class Vector1, class Vector2>
		inline Element &dotSpecializedDD (Element &res, const Vector1 &v1, const Vector2 &v2) const;

		template <class Vector1, class Vector2>
		inline Element &dotSpecializedDSP (Element &res, const Vector1 &v1, const Vector2 &v2) const;

	private:
		uint32_t Corr;
		uint32_t Max;
	};

} // namespace LinBox

#include "linbox/field/Givaro/givaro-zpz.inl"

#endif // __LINBOX_field_givaro_zpz_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: