This file is indexed.

/usr/include/linbox/algorithms/varprec-cra-early-multip.h is in liblinbox-dev 1.4.2-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
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
/* linbox/blackbox/rational-reconstruction-base.h
 * Copyright (C) 2009 Anna Marszalek
 *
 * Written by Anna Marszalek <aniau@astronet.pl>
 *
 * ========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========
 */

#ifndef __LINBOX_varprec_cra_multip_single_H
#define __LINBOX_varprec_cra_multip_single_H

#include "linbox/util/timer.h"
#include <stdlib.h>
#include "linbox/integer.h"
#include "linbox/field/gmp-rational.h"
#include "linbox/solutions/methods.h"
#include <vector>
#include <utility>
#include "linbox/algorithms/cra-early-single.h"
#include "linbox/algorithms/cra-full-multip.h"
#include "linbox/algorithms/lazy-product.h"


namespace LinBox
{

	/*
	 * Implements early terminated CRA with preconditioning of the result
	 * factor | result should be given
	 * does not detect bad factors but can run until full termination [for result] in this case
	 * factor may be changed by changeFactor function, residues stored in FullMultipCRA are recomputed in this case,
	 * FullMulpitCRA should consist of vectors of size 0, but errors happen.
	 */

	//typedef Givaro::ZRing<Integer> Integers;
	//typedef Integers::Element Integer;

	template<class Domain_Type>
	struct VarPrecEarlyMultipCRA: public EarlySingleCRA<Domain_Type>, FullMultipCRA<Domain_Type> {

		typedef GMPRationalField Rationals;
		typedef Rationals::Element Quotient;

		typedef Domain_Type                     Domain;
		typedef typename Domain::Element DomainElement;
		typedef VarPrecEarlyMultipCRA<Domain> Self_t;

	protected:
		BlasVector< Givaro::ZRing<Integer> > vfactor_;
		BlasVector< Givaro::ZRing<Integer> > vmultip_;

		std::vector< unsigned long > randv;
		Integer& result(Integer &d) {return d;}; // DON'T TOUCH
	public:
		VarPrecEarlyMultipCRA(const unsigned long EARLY = DEFAULT_EARLY_TERM_THRESHOLD, const double b=0.0,
				      const BlasVector<Givaro::ZRing<Integer> >& vf = BlasVector<Givaro::ZRing<Integer> >(Givaro::ZRing<Integer>()),
				      const BlasVector<Givaro::ZRing<Integer> >& vm = BlasVector<Givaro::ZRing<Integer> >(Givaro::ZRing<Integer>())) :
			EarlySingleCRA<Domain>(EARLY), FullMultipCRA<Domain>(b), vfactor_(vf), vmultip_(vm)
		{
			for (int i=0; i < (int)vfactor_.size(); ++i) {
				if (vfactor_[(size_t)i]==0) vfactor_[(size_t)i]=1;
			}
		}

		VarPrecEarlyMultipCRA(VarPrecEarlyMultipCRA& other) :
			EarlySingleCRA<Domain>(other.EARLY_TERM_THRESHOLD), FullMultipCRA<Domain>(other.LOGARITHMIC_UPPER_BOUND), vfactor_(other.vfactor_), vmultip_(other.vmultip_)
		{
			for (int i=0; i < vfactor_.size(); ++i) {
				if (vfactor_[(size_t)i]==0) vfactor_[(size_t)i]=1;
			}
		}

		int getThreshold(int& t) {return t = (int)EarlySingleCRA<Domain>::EARLY_TERM_THRESHOLD;}

		Integer& getModulus(Integer& m) {EarlySingleCRA<Domain>::getModulus(m);return m;}
		Integer& getResidue(Integer& r) {EarlySingleCRA<Domain>::getResidue(r);return r;}

		template<class Vect>
		Vect& getResidue(Vect& r) {
			Vect z(r.field()),vf(r.field()), vm(r.field());
			FullMultipCRA<Domain>::result(z);

			typename Vect::const_iterator it,itf,itm;
			Integer M; getModulus(M);
			getPreconditioner(vf,vm);

			//r.resize(vf.size());//vector of residues
			inverse(r, vf, M);
			normproductin(r, z, M);
			normproductin(r, vm, M);

			//FullMultipCRA<Domain>::getResidue(r);
			return r;
		}

		template<class Vect>
		void initialize (const Integer& D, const Vect& e) {
			srand48(BaseTimer::seed());
			vfactor_.resize( e.size(),1 );
			vmultip_.resize( e.size(),1 );
			randv. resize ( e.size() );

			for ( std::vector<unsigned long>::iterator int_p = randv. begin(); int_p != randv. end(); ++ int_p)
				*int_p = ((unsigned long)lrand48()) % 20000 - 10000;

			std::vector<Integer> vz(vfactor_.size());
			inverse(vz,vfactor_,D);
			productin(vz,vmultip_,D);
			productin(vz,e,D);

			Integer z;
			dot(z,D,vz,randv);

			EarlySingleCRA<Domain>::initialize(D, z);
			FullMultipCRA<Domain>::initialize(D, e);
		}

		template<class Vect>
		void initialize (const Domain& D, Vect& e) {
			srand48(BaseTimer::seed());
			vfactor_.resize( e.size(),1 );
			vmultip_.resize( e.size(),1 );
			randv. resize ( e.size() );

			for ( std::vector<unsigned long>::iterator int_p = randv. begin(); int_p != randv. end(); ++ int_p)
				*int_p = ((unsigned long)lrand48()) % 20000 - 10000;

			std::vector<DomainElement> vz(vfactor_.size());
			inverse(vz,vfactor_,D);
			productin(vz,vmultip_,D);
			productin(vz,e,D);

			DomainElement z;
			dot(z,D,vz,randv);

			EarlySingleCRA<Domain>::initialize(D, z);
			FullMultipCRA<Domain>::initialize(D, e);
		}

		template<class Vect>
		void progress (const Integer& D, const Vect& e) {

			// Could be much faster
			// - do not compute twice the product of moduli
			// - reconstruct one element of e until Early Termination,
			//   then only, try a random linear combination.

			std::vector<Integer> vz(vfactor_.size());
			inverse(vz,vfactor_,D);
			productin(vz,vmultip_,D);
			productin(vz,e,D);

			Integer z;
			dot(z,D,vz,randv);

			EarlySingleCRA<Domain>::progress(D, z);
			FullMultipCRA<Domain>::progress(D, e);
		}

		template<class Vect>
		void progress (const Domain& D, const Vect& e) {
			//z = (e/ factor mod D)
			//!@todo Could be much faster
			// - do not compute twice the product of moduli
			// - reconstruct one element of e until Early Termination,
			//   then only, try a random linear combination.

			std::vector<DomainElement> vz(vfactor_.size());
			inverse(vz,vfactor_,D);
			productin(vz,vmultip_,D);
			productin(vz,e,D);
			DomainElement z;
			dot(z,D,vz,randv);

			EarlySingleCRA<Domain>::progress(D, z);
			FullMultipCRA<Domain>::progress(D, e);
		}

		template<class OKDomain>
		void progress (const Domain& D, const BlasVector<OKDomain>& e) {
			//z = (e/ factor mod D)
			//!@todo Could be much faster
			// - do not compute twice the product of moduli
			// - reconstruct one element of e until Early Termination,
			//   then only, try a random linear combination.

			BlasVector<Domain> vz(D,vfactor_.size());
			inverse(vz,vfactor_,D);
			productin(vz,vmultip_,D);
			productin(vz,e,D);
			DomainElement z;
			dot(z,D,vz,randv);

			EarlySingleCRA<Domain>::progress(D, z);
			FullMultipCRA<Domain>::progress(D, e);
		}

		bool terminated() {
			bool ET = EarlySingleCRA<Domain>::terminated();
			if (FullMultipCRA<Domain>::LOGARITHMIC_UPPER_BOUND> 1.0) ET = ET || FullMultipCRA<Domain>::terminated();
			return ET;
		}

		bool noncoprime(const Integer& i) const {
			return EarlySingleCRA<Domain>::noncoprime(i);
		}

		//Integer& getFactor(Integer& f) {
		//	return f = EarlySingleCRA<Domain>::factor_;
		//}

		//Integer& getMultip(Integer& m) {
		//	return m=EarlySingleCRA<Domain>::multip_;
		//}

		template<class Vect>
		Vect& getFactor(Vect& vf) const {
			//Integer f = getFactor(f);
			vf.clear();// vf.resize(vfactor_.size());
			typename Vect::const_iterator it = vfactor_.begin();
			for (;it != vfactor_.end(); ++it) {
				vf.push_back((*it));
			}
			return vf;// = vfactor_;
		}


		template<class Vect>
		Vect& getMultip(Vect& vm) const {
			//Integer m = getMultip(m);
			vm.clear(); //vm.resize(vmultip_ .size());
			typename Vect::const_iterator it = vmultip_.begin();
			for (;it != vmultip_.end(); ++it) {
				vm.push_back((*it));
			}
			return vm;
		}

		//Integer& getPreconditioner(Integer& f, Integer& m) const {
		//	getMultip(m);
		//	return getFactor(f);
		//}

		template<class Vect>
		Vect& getPreconditioner(Vect& vf, Vect& vm) const {
			getMultip(vm);
			getFactor(vf);
			return vf;
		}

		//Quotient& getPreconditioner(Quotient& q) {
		//	return q = EarlySingleCRA<Domain>::getPreconditioner(q);
		//}

		template<template<class, class> class Vect, template<class> class Alloc>
		Vect<Quotient, Alloc<Quotient> >& getPreconditioner(Vect<Quotient, Alloc<Quotient> >& vq) const {

			Vect<Integer, Alloc<Integer> > vf,vm;
			getPreconditioner(vf,vm);
			vq.clear();

			typename Vect<Integer, Alloc<Integer> >::const_iterator itf, itm;
			for (itf = vf.begin(), itm=vm.begin() ; itf != vf.end(); ++itf,++itm) {
				vq.push_back(Quotient(*itm,*itf));
			}

			return vq;
		}

		template<template<class, class> class Vect, template<class> class Alloc>
		Vect<Integer, Alloc<Integer> >& result(Vect<Integer, Alloc<Integer> >& r) {
			if ((FullMultipCRA<Domain>::LOGARITHMIC_UPPER_BOUND> 1.0) && ( FullMultipCRA<Domain>::terminated() )) {
				FullMultipCRA<Domain>::result(r);
				return r ;
			}
			else {
				//Integer M; getModulus(m);
				Vect<Integer, Alloc<Integer> > z,vf, vm;
				FullMultipCRA<Domain>::result(z);

				typename Vect<Integer, Alloc<Integer> >::const_iterator it,itf,itm;

				Integer M; getModulus(M);
				getPreconditioner(vf,vm);

				Vect<Integer, Alloc<Integer> > residue;
				getResidue(residue);
				//vector of residues

				r.clear();

				//getPreconditioner(vf,vm);
				itf = vf.begin(); itm = vm.begin();it = z.begin();

				for (; it!= z.end(); ++it, ++itf,++itm ) {
					r.push_back(*itf * (*it) / (*itm) );
				}
				return r;
			}
		}

		template<template<class,class> class Vect, template<class> class Alloc>
		Vect<Integer, Alloc<Integer> >& result(Vect<Integer, Alloc<Integer> >& num, Integer& den)
		{
			if ((FullMultipCRA<Domain>::LOGARITHMIC_UPPER_BOUND> 1.0) && ( FullMultipCRA<Domain>::terminated() )) {
				FullMultipCRA<Domain>::result(num);
				den = 1;
				return num;
			}
			else {
				Vect<Integer, Alloc<Integer> > z,vf, vm;
				FullMultipCRA<Domain>::result(z);//vector of non prec results

				typename Vect<Integer, Alloc<Integer> >::const_iterator it,itf,itm;
				typename Vect<Integer, Alloc<Integer> >::iterator itt;

				Integer M; getModulus(M);
				getPreconditioner(vf,vm);

				Vect<Integer, Alloc<Integer> > residue;//vector of residues
				getResidue(residue);

				num.clear();

				//getPreconditioner(vf,vm);
				itf = vf.begin(); itm = vm.begin();it = residue.begin();
				den = 1; Integer old_den =1;
				for (; it!= residue.end(); ++it, ++itf,++itm ) {
					lcm(den,den,*itm);Integer d = den/old_den;

					num.push_back((*itf) * (*it));
					if (den != old_den) {
						for (itt=num.begin(); itt !=num.end()-1 ;++itt) {
							*itt *= d;
						}
						*itt = *itt * (den/ (*itm));
					}
					old_den = den;
				}
				return num;
			}
		}

		BlasVector<Givaro::ZRing<Integer> >& result(BlasVector<Givaro::ZRing<Integer> >& num, Integer& den)
		{
			if ((FullMultipCRA<Domain>::LOGARITHMIC_UPPER_BOUND> 1.0) && ( FullMultipCRA<Domain>::terminated() )) {
				FullMultipCRA<Domain>::result(num);
				den = 1;
				return num;
			}
			else {
				Givaro::ZRing<Integer> Z;
				BlasVector<Givaro::ZRing<Integer> > z(Z),vf(Z), vm(Z);
				FullMultipCRA<Domain>::result(z);//vector of non prec results

				typename BlasVector<Givaro::ZRing<Integer> >::const_iterator it,itf,itm;
				typename BlasVector<Givaro::ZRing<Integer> >::iterator itt;

				Integer M; getModulus(M);
				getPreconditioner(vf,vm);

				BlasVector<Givaro::ZRing<Integer> > residue(Z);//vector of residues
				getResidue(residue);

				num.clear();

				//getPreconditioner(vf,vm);
				itf = vf.begin(); itm = vm.begin();it = residue.begin();
				den = 1; Integer old_den =1;
				for (; it!= residue.end(); ++it, ++itf,++itm ) {
					lcm(den,den,*itm);Integer d = den/old_den;

					num.push_back((*itf) * (*it));
					if (den != old_den) {
						for (itt=num.begin(); itt !=num.end()-1 ;++itt) {
							*itt *= d;
						}
						*itt = *itt * (den/ (*itm));
					}
					old_den = den;
				}
				return num;
			}
		}

		template<template<class, class> class Vect, template<class> class Alloc>
		Vect<Quotient, Alloc<Quotient> >& result(Vect<Quotient, Alloc<Quotient> >& q)
		{
			q.clear();
			if ((FullMultipCRA<Domain>::LOGARITHMIC_UPPER_BOUND> 1.0) && ( FullMultipCRA<Domain>::terminated() )) {
				std::vector<Integer> vz;
				FullMultipCRA<Domain>::result(vz);

				typename Vect<Integer, Alloc<Integer> >::const_iterator it = vz.begin();
				for (; it!= vz.end(); ++it) {
					q.push_back(Quotient(*it,1));
				}
				return q;
			}
			else {
				Vect<Integer, Alloc<Integer> > z,vf, vm;
				FullMultipCRA<Domain>::result(z);
				typename Vect<Integer, Alloc<Integer> >::const_iterator it = z.begin(),itf,itm;

				Integer M; getModulus(M);
				getPreconditioner(vf,vm);

				Vect<Integer, Alloc<Integer> > residue;//vector of residues
				inverse(residue, vf, M);
				normproductin(residue, z, M);
				normproductin(residue, vm, M);

				itf = vf.begin(); itm = vm.begin();

				for (; it!= z.end(); ++it, ++itf,++itm ) {
					q.push_back(Quotient(*itf * (*it) , *itm));
				}
				return q;
			}
		}


		template<class Vect>
		bool changePreconditioner(const Vect& vf, const Vect& vm) {
			//Warning does not detect unchanged preconditioners !!!
			//if ((factor_ == f) && (multip_==m)) return EarlySingleCRA<Domain>::terminated();

			typename Vect::const_iterator itf, itm, itf2, itm2;

			vfactor_ = vf;
			for (int i=0; i < (int)vfactor_.size(); ++i) {
				if (vfactor_[(size_t)i]==0) vfactor_[(size_t)i]=1;	//if factor ==0 set no factor
			}
			vmultip_ = vm;

			Givaro::ZRing<Integer> Z;
			Vect e(Z,vfactor_.size());

			//clear CRAEarlySingle;
			EarlySingleCRA<Domain>::occurency_ = 0;
			EarlySingleCRA<Domain>::nextM_ = 1;
			EarlySingleCRA<Domain>::primeProd_ = 1;
			EarlySingleCRA<Domain>::residue_ = 0;

			//Computation of residue_

			//std::vector< double >::iterator  _dsz_it = RadixSizes_.begin();
			std::vector< LazyProduct >::iterator _mod_it = FullMultipCRA<Domain>::RadixPrimeProd_.end();// list of prime products
			std::vector< BlasVector<Givaro::ZRing<Integer> > >::iterator _tab_it = FullMultipCRA<Domain>::RadixResidues_.end();// list of residues as vectors of size 1
			std::vector< bool >::iterator    _occ_it = FullMultipCRA<Domain>::RadixOccupancy_.end();//flags of occupied fields
			int n = (int)FullMultipCRA<Domain>::RadixOccupancy_.size();
			//std::vector<Integer> ri(1); LazyProduct mi; double di;
			//could be much faster if max occupandy is stored
			int prev_shelf=0, shelf = 0; Integer prev_residue_=0;
			--_occ_it; --_mod_it; --_tab_it;//last elemet
			for (int i=n; i > 0; --i, --_mod_it, --_tab_it, --_occ_it ) {
				//--_occ_it; --_mod_it; --_tab_it;
				++shelf;
				if (*_occ_it) {
					Integer D = _mod_it->operator()();
					Vect e_v(Z,vfactor_.size());
					inverse(e_v,vfactor_,D);
					productin(e_v,*_tab_it,D);
					productin(e_v,vmultip_,D);

					Integer z;
					dot(z,D, e_v, randv);


					prev_residue_ = EarlySingleCRA<Domain>::residue_;
					EarlySingleCRA<Domain>::progress(D,z);

					if (prev_residue_ == EarlySingleCRA<Domain>::residue_ ) {
						EarlySingleCRA<Domain>::occurency_ = EarlySingleCRA<Domain>::occurency_ + (unsigned int) (shelf - prev_shelf);
					}
					if ( EarlySingleCRA<Domain>::terminated() ) {
						return true;
					}
					prev_shelf = shelf;
				}
			}

			return EarlySingleCRA<Domain>::terminated();

			//forall results in FullMultipCRA do
			//	precondition
			//	progress to  EarlySingleCRA
			//	check for termination
			//recompute
		}

		bool changeVector() {
			for ( std::vector<unsigned long>::iterator int_p = randv. begin();int_p != randv. end(); ++ int_p)
				*int_p = ((unsigned long)lrand48()) % 20000;
			return changePreconditioner(vfactor_,vmultip_);
		}

	protected:
		template <template<class> class Alloc, template<class, class> class Vect1, class Vect2>
		DomainElement& dot (DomainElement& z, const Domain& D,
				    const Vect1<DomainElement, Alloc<DomainElement> >& v1,
				    const Vect2& v2)
		{
			D.assign(z,D.zero); DomainElement tmp;
			typename Vect1<DomainElement, Alloc<DomainElement> >::const_iterator v1_p;
			typename Vect2::const_iterator v2_p;

			for (v1_p  = v1. begin(), v2_p = v2. begin();v1_p != v1. end();++ v1_p, ++ v2_p)
				D.axpyin(z, (*v1_p), D.init(tmp, (*v2_p)));
			return z;
		}

		template<class Vect2>
		DomainElement& dot (DomainElement& z, const Domain& D,
				    const BlasVector<Domain>& v1,
				    const Vect2& v2)
		{
			D.assign(z,D.zero); DomainElement tmp;
			typename BlasVector<Domain>::const_iterator v1_p;
			typename Vect2::const_iterator v2_p;

			for (v1_p  = v1. begin(), v2_p = v2. begin();v1_p != v1. end();++ v1_p, ++ v2_p)
				D.axpyin(z, (*v1_p), D.init(tmp, (*v2_p)));
			return z;
		}


		template <template<class> class Alloc, template<class, class> class Vect1, class Vect2>
		Integer& dot (Integer& z, const Integer& D, const Vect1<Integer, Alloc<Integer> >& v1, const Vect2& v2)
		{
			z = 0;
			typename Vect1<Integer, Alloc<Integer> >::const_iterator v1_p;
			typename Vect2::const_iterator v2_p;
			for (v1_p  = v1. begin(), v2_p = v2. begin(); v1_p != v1. end(); ++ v1_p, ++ v2_p) {
				z = (z + (*v1_p)*(*v2_p))%D;
			}
			return z;
		}

		template<class Vect2>
		Integer& dot (Integer& z, const Integer& D, const BlasVector<Givaro::ZRing<Integer> >& v1, const Vect2& v2)
		{
			z = 0;
			typename BlasVector<Givaro::ZRing<Integer> >::const_iterator v1_p;
			typename Vect2::const_iterator v2_p;
			for (v1_p  = v1. begin(), v2_p = v2. begin(); v1_p != v1. end(); ++ v1_p, ++ v2_p) {
				z = (z + (*v1_p)*int64_t(*v2_p))%D;
			}
			return z;
		}


		template<class Vect1, class Vect2>
		Vect1& inverse(Vect1& vz,const Vect2& vf, const Domain D)
		{
			vz.clear();
			typename Vect2::const_iterator it = vf.begin();

			for (; it != vf.end(); ++it) {
				DomainElement z,i;
				D.assign(z,D.one);
				D.init(i,*it);
				if (!D.isZero(i)) D.inv(z,i);
				vz.push_back(z);
			}
			return vz;

		}

		template<class Vect1, class Vect2>
		Vect1& inverse(Vect1& vz,const Vect2& vf, const Integer& D)
		{
			vz.clear();
			typename Vect2::const_iterator it = vf.begin();

			for (; it != vf.end(); ++it) {
				Integer z=1;
				if ((*it) != 0) inv(z,*it,D);
				vz.push_back(z);
			}
			return vz;
		}

	public:
		template<class Vect1, class Vect2>
		Vect1& productin(Vect1& vz, const Vect2 &vm, const Domain D) {
			typename Vect1::iterator v1_p;
			typename Vect2::const_iterator v2_p;

			for (v1_p  = vz. begin(), v2_p = vm. begin(); v1_p != vz. end(); ++ v1_p, ++ v2_p) {
				DomainElement i;
				D.init(i,*v2_p);
				D.mulin(*v1_p , i);
			}
			return vz;
		}


		template<class Vect1, class Vect2>
		Vect1& productin(Vect1& vz, const Vect2 vm, const Integer& D) {
			typename Vect1::iterator v1_p;
			typename Vect2::const_iterator v2_p;

			for (v1_p  = vz. begin(), v2_p = vm. begin(); v1_p != vz. end(); ++ v1_p, ++ v2_p) {
				*v1_p = (*v1_p) * (*v2_p);
				*v1_p = (*v1_p) % D;
			}
			return vz;
		}

		template<class Vect1, class Vect2>
		Vect1& normproductin(Vect1& vz, const Vect2 vm, const Integer& D) {
			typename Vect1::iterator v1_p;
			typename Vect2::const_iterator v2_p;
			for (v1_p  = vz. begin(), v2_p = vm. begin(); v1_p != vz. end(); ++ v1_p, ++ v2_p) {
				*v1_p = (*v1_p) * (*v2_p);
				*v1_p = (*v1_p) % D;
				Integer tmp = (*v1_p >0) ? *v1_p - D : *v1_p + D;
				if (absCompare(*v1_p,tmp)> 0) *v1_p = tmp;
			}
			return vz;
		}

		template<class Vect1, class Vect2>
		Vect1& productin(Vect1& vz, const Vect2 vm) {
			typename Vect1::iterator v1_p;
			typename Vect2::const_iterator v2_p;

			for (v1_p  = vz. begin(), v2_p = vm. begin(); v1_p != vz. end(); ++ v1_p, ++ v2_p) {
				*v1_p *= (*v2_p);
			}

			return vz;
		}

	};

} //namespace LinBox

#endif //__LINBOX_varprec_cra_multip_single_H


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