This file is indexed.

/usr/include/givaro/givfractiondomain.h is in libgivaro-dev 3.7.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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
// ===============================================================
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// Time-stamp: <20 Jan 11 08:59:29 Jean-Guillaume.Dumas@imag.fr>
// Author: J-G. Dumas
// Description: fractions over a Ring domain
// ===============================================================
#ifndef __GIVARO_frac_domain_H
#define __GIVARO_frac_domain_H
#include <givaro/givpower.h>

#ifndef GIVABS
#define GIVABS(a) ((a)>0?(a):-(a))
#endif

namespace Givaro {
template<class T1, class T2>
struct Frac {
	T1 _num;
	T2 _den;
	Frac() {}
	template<class Z1, class Z2>
	Frac( const Z1& v1, const Z2& v2) : _num(v1), _den(v2) {}
	T1& nume() { return _num; }
	const T1& nume() const
	{ return _num; }
	T2& deno() { return _den; }
	const T2& deno() const
	{ return _den; }
};


template<class RingDom>
struct FracDom : public RingDom {

public :
	// -- Self_t
	typedef          FracDom<RingDom>		Self_t;

	// -- Exported types
	typedef	     RingDom			Ring_t;
	typedef typename RingDom::Element	Ring_E;
	typedef Frac<Ring_E, Ring_E>		Element;
	typedef Frac<Ring_E, Ring_E>		Rep;

	// -- Constantes
	const Rep zero;
	const Rep one;
	const Rep mOne;

	void reduce(Ring_E& a, Ring_E& b) const
	{
		Ring_E g; Ring_t::gcd(g,a,b);
		// Ring_t::write(std::cerr << "a BEF: ", a) << std::endl;
		// Ring_t::write(std::cerr << "b BEF: ", b) << std::endl;
		// Ring_t::write(std::cerr << "g GCD: ", g) << std::endl;
		if(! ( Ring_t::isOne(g) || Ring_t::isZero(g) ) ) {
			Ring_t::divin(a,g);
			Ring_t::divin(b,g);
		}
		// Ring_t::write(std::cerr << "a AFT: ", a) << std::endl;
		// Ring_t::write(std::cerr << "b AFT: ", b) << std::endl;
	}

	Rep& reduce(Rep& r) const
	{
		reduce(r._num,r._den);
		return r;
	}


	FracDom (const RingDom& R ) : Ring_t(R), zero(R.zero,R.one), one(R.one,R.one) , mOne(R.mOne,R.one){}
	FracDom (const Self_t& F) : Ring_t(static_cast<const Ring_t&>(F)), zero(F.zero), one(F.one), mOne(F.mOne) {}
	const Ring_t& getdomain() const
	{ return static_cast<const Ring_t&>(*this); }
	const Ring_t& getring() const
	{ return static_cast<const Ring_t&>(*this); }

	Rep& init(Rep& a) const
	{ Ring_t::init(a._num); Ring_t::init(a._den); return a; }

	template<class XXX>
	Rep& init(Rep& p, const XXX &cste ) const
	{
		Ring_t::init(p._num,cste); Ring_t::assign(p._den,Ring_t::one);
		return p;
	}


	// -- Assignment p = q
	Rep& assign( Rep& p, const Rep& q) const
	{
		Ring_t::assign(p._num,q._num); Ring_t::assign(p._den,q._den);
		return p;
	}
	Rep& assign( Rep& p, const Ring_E& q) const
	{
		Ring_t::assign(p._num,q); Ring_t::assign(p._den,Ring_t::one);
		return p;
	}

	// -- Comparaison operator
	int isZero  ( const Rep& P ) const
	{ return Ring_t::isZero(P._num); }
	int isOne   ( const Rep& P ) const
	{ return Ring_t::areEqual(P._num, P._den); }
	int areEqual ( const Rep& P, const Rep& Q ) const
	{
		return Ring_t::areEqual(P._num, Q._num) && Ring_t::areEqual(P._den, Q._den) ; }
		int areNEqual( const Rep& P, const Rep& Q ) const
		{
			return Ring_t::areNEqual(P._num, Q._num) || Ring_t::areNEqual(P._den, Q._den) ;
		}

		// --
		std::istream& read ( std::istream& i ) {
			char tmp; i >> tmp; // '('
			Ring_t::read(i);
			return i >> tmp; // ')'
		}
		std::ostream& write( std::ostream& o ) const
		{
			return Ring_t::write(o << '(') << ')';
		}
		std::istream& read ( std::istream& i, Rep& n) const
		{
			char tmp;
			i >> tmp; GIVARO_ASSERT(tmp == '(', "Error in fraction read '(' not found");
			Ring_t::read(i,n._num);
			i >> tmp; GIVARO_ASSERT(tmp == ')', "Error in fraction read ')' not found");
			i >> tmp; GIVARO_ASSERT(tmp == '/', "Error in fraction read '/' not found");
			i >> tmp; GIVARO_ASSERT(tmp == '(', "Error in fraction read '(' not found");
			Ring_t::read(i,n._den);
			i >> tmp; GIVARO_ASSERT(tmp == ')', "Error in fraction read ')' not found");
			return i;
		}
		std::ostream& write( std::ostream& o, const Rep& n) const
		{
			return Ring_t::write(Ring_t::write(o << '(',n._num) << ")/(", n._den) << ')';
		}

		// -- Arithmetics operators
		Rep& mulin ( Rep& q, const Rep& a ) const
		{
			Ring_t::mulin(q._num,a._num);
			Ring_t::mulin(q._den,a._den);
			return reduce(q);
		}
		Rep& mulin ( Rep& q, const Ring_E& a ) const
		{
			Ring_E u(a);
			reduce(u,q._den);
			Ring_t::mulin(q._num,u);
			return q;
		}
		Rep& mul   ( Rep& q, const Rep& a, const Ring_E& b ) const
		{
			Ring_E u(b),v(a._den);
			reduce(u,v);
			Ring_t::mul(q._num,a._num,u);
			Ring_t::assign(q._den,v);
			return q;
		}

		Rep& mul   ( Rep& q, const Ring_E& a, const Rep& b ) const
		{
			return mul(q,b,a);
		}

		Rep& mul   ( Rep& q, const Rep& a, const Rep& b ) const
		{
			Ring_t::mul(q._num,a._num,b._num);
			Ring_t::mul(q._den,a._den,b._den);
			return reduce(q);
		}


		Rep& addin ( Rep& res, const Rep& u ) const
		{
			Ring_E g; Ring_t::gcd(g, res._den, u._den);
			Ring_E ud; Ring_t::div(ud, u._den, g);
			Ring_E vd; Ring_t::div(vd, res._den, g);
			Ring_t::mulin(res._num, ud);
			Ring_t::mulin(res._den, ud); // res *= uden/g
			Ring_t::mulin(vd, u._num);   // unum*= rden/g
			Ring_t::addin(res._num,vd);
			return reduce(res);
		}

		Rep& addin ( Rep& res, const Ring_E& a ) const
		{
			Ring_t::axpyin(res._num,res._den,a);
			return reduce(res);
		}

		Rep& add ( Rep& res, const Rep& u, const Rep& v ) const
		{
			Ring_E g; Ring_t::gcd(g, u._den, v._den);
			Ring_E ud; Ring_t::div(ud, u._den, g);
			Ring_E vd; Ring_t::div(vd, v._den, g);
			Ring_t::mul(res._num, u._num, vd);
			Ring_t::mul(res._den, u._den, vd); // res = u * vden/g
			Ring_t::mulin(ud, v._num);         // vnum* uden/g
			Ring_t::addin(res._num,ud);
			return reduce(res);
		}

		Rep& add ( Rep& res, const Rep& u, const Ring_E& a) const
		{
			Ring_t::axpy(res._num,u._num,u._den,a);
			Ring_t::assign(res._den,u._den);
			return reduce(res);
		}

		Rep& add ( Rep& res, const Ring_E& a, const Rep& u) const
		{
			return add(res,u,a);
		}

		Rep& subin ( Rep& res, const Rep& u ) const
		{
			Ring_E g; Ring_t::gcd(g, res._den, u._den);
			Ring_E ud; Ring_t::div(ud, u._den, g);
			Ring_E vd; Ring_t::div(vd, res._den, g);
			Ring_t::mulin(res._num, ud);
			Ring_t::mulin(res._den, ud); // res *= uden/g
			Ring_t::mulin(vd, u._num);   // unum*= rden/g
			Ring_t::subin(res._num,vd);
			return reduce(res);
		}

		Rep& subin ( Rep& res, const Ring_E& a ) const
		{
			Ring_t::maxpyin(res._num,res._den,a);
			return reduce(res);
		}

		Rep& sub ( Rep& res, const Rep& u, const Rep& v ) const
		{
			Ring_E g; Ring_t::gcd(g, u._den, v._den);
			Ring_E ud; Ring_t::div(ud, u._den, g);
			Ring_E vd; Ring_t::div(vd, v._den, g);
			Ring_t::mul(res._num, u._num, vd);
			Ring_t::mul(res._den, u._den, vd); // res = u * vden/g
			Ring_t::mulin(ud, v._num);         // vnum* uden/g
			Ring_t::subin(res._num,ud);
			return reduce(res);
		}

		Rep& sub ( Rep& res, const Rep& u, const Ring_E& a) const
		{
			Ring_t::maxpy(res._num,u._den,a,u._num);
			Ring_t::assign(res._den,u._den);
			return reduce(res);
		}

		Rep& sub ( Rep& res, const Ring_E& a, const Rep& u) const
		{
			Ring_t::axmy(res._num,a,u._den,u._num);
			Ring_t::assign(res._den,u._den);
			return reduce(res);
		}

		Rep& negin ( Rep& res ) const
		{ Ring_t::negin(res._num); return res; }
		Rep& neg ( Rep& res, const Rep& u ) const
		{
			Ring_t::neg(res._num,u._num);
			Ring_t::assign(res._den,u._den);
			return res;
		}

		Rep& invin ( Rep& q) const
		{
			std::swap(q._num,q._den);
			return q;
		}

		Rep& inv( Rep& r, const Rep& u) const
		{
			Ring_t::assign(r._num, u._den);
			Ring_t::assign(r._den, u._num);
			return r;
		}
		Rep& inv(Rep& r, const Ring_E& a) {
			Ring_t::assign(r._den,a);
			Ring_t::assign(r._num,Ring_t::one);
			return r;
		}

		Rep& divin ( Rep& q, const Rep& a ) const
		{
			invin(q); mulin(q,a); return invin(q);
		}

		Rep& divin ( Rep& q, const Ring_E& a ) const
		{
			invin(q); mulin(q,a); return invin(q);
		}

		Rep& div   ( Rep& q, const Rep& a, const Rep& b ) const
		{
			inv(q,b); return mulin(q,a);
		}

		Rep& axpy  (Rep& r, const Rep& a, const Rep& x, const Rep& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Rep& a, const Ring_E& x, const Rep& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Rep& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Ring_E& a, const Rep& x, const Rep& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Ring_E& a, const Ring_E& x, const Rep& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Ring_E& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,x,y);
			return addin(r,a);
		}
		Rep& axpy  (Rep& r, const Rep& a, const Ring_E& x, const Ring_E& y) const
		{
			Ring_E m;Ring_t::mul(m,x,y);
			return add(r,a,m);
		}

		Rep& axpyin(Rep& r, const Rep& a, const Rep& x) const
		{
			Rep m; mul(m,a,x);
			return addin(r,m);
		}
		Rep& axpyin(Rep& r, const Ring_E& a, const Rep& x) const
		{
			Rep m; mul(m,a,x);
			return addin(r,m);
		}
		Rep& axpyin(Rep& r, const Rep& a, const Ring_E& x) const
		{
			Rep m; mul(m,a,x);
			return addin(r,m);
		}
		Rep& axpyin(Rep& r, const Ring_E& a, const Ring_E& x) const
		{
			Ring_E m; mul(m,a,x);
			return addin(r,m);
		}
		// -- maxpy: r <- y - a * x
		Rep& maxpy  (Rep& r, const Rep& a, const Rep& x, const Rep& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}
		Rep& maxpy  (Rep& r, const Rep& a, const Ring_E& x, const Rep& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}
		Rep& maxpy  (Rep& r, const Rep& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}
		Rep& maxpy  (Rep& r, const Ring_E& a, const Rep& x, const Rep& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}
		Rep& maxpy (Rep& r, const Ring_E& a, const Ring_E& x, const Rep& y) const
		{
			Ring_E m;Ring_t::mul(m,x,a);
			return sub(r,y,m);
		}
		Rep& maxpy  (Rep& r, const Ring_E& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}
		Rep& maxpy  (Rep& r, const Rep& a, const Ring_E& x, const Ring_E& y) const
		{
			mul(r,x,a); negin(r);
			return addin(r,y);
		}

		// -- axmyin: r <-  a * x - r
		Rep& axmyin(Rep& r, const Rep& a, const Rep& x) const
		{
			maxpyin(r,a,x);
			return negin(r);
		}
		Rep& axmyin(Rep& r, const Ring_E& a, const Rep& x) const
		{
			maxpyin(r,a,x);
			return negin(r);
		}
		Rep& axmyin(Rep& r, const Rep& a, const Ring_E& x) const
		{
			maxpyin(r,a,x);
			return negin(r);
		}
		Rep& axmyin(Rep& r, const Ring_E& a, const Ring_E& x) const
		{
			maxpyin(r,a,x);
			return negin(r);
		}
		// -- maxpyin: r <- r - a * x
		Rep& maxpyin(Rep& r, const Rep& a, const Rep& x) const
		{
			Rep m; mul(m,a,x);
			return subin(r,m);
		}
		Rep& maxpyin(Rep& r, const Ring_E& a, const Rep& x) const
		{
			Rep m; mul(m,a,x);
			return subin(r,m);

		}
		Rep& maxpyin(Rep& r, const Rep& a, const Ring_E& x) const
		{
			Rep m; mul(m,a,x);
			return subin(r,m);

		}
		Rep& maxpyin(Rep& r, const Ring_E& a, const Ring_E& x) const
		{
			Ring_E m; mul(m,a,x);
			return subin(r,m);
		}
		// -- axmy: r <- a * x - y
		Rep& axmy  (Rep& r, const Rep& a, const Rep& x, const Rep& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}
		Rep& axmy  (Rep& r, const Ring_E& a, const Rep& x, const Rep& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}
		Rep& axmy  (Rep& r, const Rep& a, const Ring_E& x, const Rep& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}
		Rep& axmy  (Rep& r, const Rep& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}
		Rep& axmy  (Rep& r, const Ring_E& a, const Ring_E& x, const Rep& y) const
		{
			Ring_E m; mul(m,a,x);
			return sub(r,m,y);
		}
		Rep& axmy  (Rep& r, const Ring_E& a, const Rep& x, const Ring_E& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}
		Rep& axmy  (Rep& r, const Rep& a, const Ring_E& x, const Ring_E& y) const
		{
			mul(r,a,x);
			return subin(r,y);
		}

		// -- misc
		// -- W <-- P^n
		Rep& pow( Rep& W, const Rep& P, long n) const
		{
			unsigned long l = (unsigned long)GIVABS(n);
			if (n>0) {
				dom_power(W._num,P._num,l,static_cast<Ring_t&>(*this));
				dom_power(W._den,P._den,l,static_cast<Ring_t&>(*this));
			} else {
				dom_power(W._num,P._den,l,static_cast<Ring_t&>(*this));
				dom_power(W._den,P._num,l,static_cast<Ring_t&>(*this));
			}
			return W;
		}

		// -- Random generators
		template< class RandIter > Rep& random(RandIter& g, Rep& r) const
		{
			Ring_t::random(g, r._num);
			Ring_t::nonzerorandom(g, r._den);
			return r;
		}

		template< class RandIter, class XXX > Rep& random(RandIter& g, Rep& r, const XXX& s) const
		{
			Ring_t::random(g, r._num, s);
			Ring_t::nonzerorandom(g, r._den, s);
			return r;
		}

		template< class RandIter > Rep& nonzerorandom(RandIter& g, Rep& r) const
		{
			Ring_t::nonzerorandom(g, r._num);
			Ring_t::nonzerorandom(g, r._den);
			return r;
		}
		template< class RandIter, class XXX  > Rep& nonzerorandom(RandIter& g, Rep& r, const XXX& s) const
		{
			Ring_t::nonzerorandom(g, r._num, s);
			Ring_t::nonzerorandom(g, r._den, s);
			return r;
		}

};

} // Givaro

#endif
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s