This file is indexed.

/usr/include/givaro/givmatdenseops.inl is in libgivaro-dev 3.7.2-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
// ==========================================================================
// $Source: /var/lib/cvs/Givaro/src/library/matrix/givmatdenseops.inl,v $
// 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.
// Authors: T. Gautier
// $Id: givmatdenseops.inl,v 1.3 2011-01-19 18:29:09 bboyer Exp $
// ==========================================================================

#error "this looks very much like dead code"

namespace Givaro {
#pragma message "#warning this file will probably not compile"

template<class Domain>
int MatrixDom<Domain,Dense>::areEqual ( const Rep& A, const Rep& B ) const
{
	if (ncol(A) != ncol(B)) return 0;
	if (nrow(A) != nrow(B)) return 0;
	return _supportdomain.areEqual(A,B);
}

template<class Domain>
int MatrixDom<Domain,Dense>::areNEqual ( const Rep& A, const Rep& B ) const
{
	return !areEqual(A,B);
}

template<class Domain>
int MatrixDom<Domain,Dense>::iszero ( const Rep& A ) const
{
	return _supportdoamin.iszero(A);
}

// res <- A + B; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::add( Rep& R, const Rep& A, const Rep& B) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)) && (ncol(A) == ncol(B)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)) && (nrow(A) == nrow(B)), "Bad size");
	_supportdomain.add(R,A,B);
}

// res <- res + A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::addin( Rep& R, const Rep& A ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	_supportdomain.addin(R,A);
}

// res <- A + val; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::add( Rep& R, const Rep& A, const Type_t& val ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	long i;
	size_t min = (ncol(R) < nrow(R) ? ncol(R) : nrow(R));
	for (i=min; --i>=0; ) _domain.add(R(i,i), A(i,i), val);
}

// res <- val + A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::add( Rep& R, const Type_t& val, const Rep& A) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	long i;
	size_t min = (ncol(R) < nrow(R) ? ncol(R) : nrow(R));
	for (i=min; --i>=0; ) _domain.add(R(i,i), A(i,i), val);
}



// res <- A - B; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::sub( Rep& R, const Rep& A, const Rep& B) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)) && (ncol(A) == ncol(B)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)) && (nrow(A) == nrow(B)), "Bad size");
	_supportdomain.sub(R,A,B);
}

// res <- res - A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::subin( Rep& R, const Rep& A ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	_supportdomain.subin(R,A);
}

// res <- res - A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::sub( Rep& R, const Rep& A, const Type_t& val ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	long i;
	size_t min = (ncol(R) < nrow(R) ? ncol(R) : nrow(R));
	for (i=min; --i>=0; ) _domain.sub(R(i,i), A(i,i), val);
}

// res <- res - A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::sub( Rep& R, const Type_t& val, const Rep& A) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	long i;
	size_t min = (ncol(R) < nrow(R) ? ncol(R) : nrow(R));
	for (i=min; --i>=0; ) _domain.sub(R(i,i), val, A(i,i));
};

// res <- - A; aliases of operands are allowed
template<class Domain>
void MatrixDom<Domain,Dense>::neg( Rep& R, const Rep& A) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	_supportdomain.neg(R,A);
}

template<class Domain>
void MatrixDom<Domain,Dense>::negin( Rep& R ) const
{
	_supportdomain.negin(R);
}


// R <- A * B, R cannot be an alias for A or B
template<class Domain>
void MatrixDom<Domain,Dense>::mul( Rep& A, const Rep& B, const Rep& C) const
{
	GIVARO_ASSERT((ncol(A) == ncol(B)) && (ncol(B) == ncol(C)), "Bad size");
	GIVARO_ASSERT((nrow(A) == nrow(B)) && (nrow(B) == nrow(C)), "Bad size");
	Indice_t k, i, j;
	int startBi, startCj, startAi;
	Indice_t nrA = nrow(A);
	Indice_t ncA = ncol(A);
	Indice_t ncB = ncol(B);

	// -- the algorithm used the fact that matrices are stored by row
	Type_t tmp;
	for (i=0; i < nrA; ++i)
	{
		startAi = i*ncA;
		for (j=0; j < ncA; ++j, ++startAi)
		{
			startBi = i*ncB; startCj = j;
			_domain.assign(tmp, _domain.zero);
			for (k=0; k<ncB; ++k, ++startBi, startCj+=ncA) // ncA = ncC
				_domain.axpy(tmp, B[startBi], C[startCj], tmp);
			_domain.assign( A[startAi], tmp );
		}
	}
}

template<class Domain>
void MatrixDom<Domain,Dense>::mulin
( Rep& R, const Type_t& val) const
{
	_supportdomain.mulin(R, val);
}

template<class Domain>
void MatrixDom<Domain,Dense>::mul
( typename VectorDom<Domain,Dense>::Rep& res,
  const Rep& M,
  const VectorDom<Domain,Dense>& VD,
  const typename VectorDom<Domain,Dense>::Rep& u ) const
{
	GIVARO_ASSERT( (nrow(M) == VD.dim(res)), "Bad size");
	GIVARO_ASSERT( (ncol(M) == VD.dim(u)), "Bad size");
	Indice_t k, i, j;
	int startMi;
	Indice_t nrM = nrow(M);
	Indice_t ncM = ncol(M);

	// -- the algorithm used the fact that matrices are stored by row
	for (i=0; i < nrM; ++i)
	{
		_domain.assign(res[i], _domain.zero);
		startMi = i*ncM;
		for (j=0; j < ncM; ++j, ++startMi)
			_domain.axpyin(res[i], M[startMi], u[j]);
	}
}


// res <- tr(u) * tr(A)
template<class Domain>
void MatrixDom<Domain,Dense>::multrans
( typename VectorDom<Domain,Dense>::Rep& res,
  const Rep& M,
  const VectorDom<Domain,Dense>& VD,
  const typename VectorDom<Domain,Dense>::Rep& u ) const
{
	GIVARO_ASSERT( (nrow(M) == VD.dim(u)), "Bad size");
	GIVARO_ASSERT( (ncol(M) == VD.dim(res)), "Bad size");
	Indice_t k, i, j;
	int startMi;
	Indice_t nrM = nrow(M);
	Indice_t ncM = ncol(M);

	// -- the algorithm used the fact that matrices are stored by row
	for (j=0; j < ncM; ++j)
		_domain.assign(res[j], _domain.zero);
	for (i=0; i < nrM; ++i)
	{
		startMi = i*ncM;
		for (j=0; j < ncM; ++j, ++startMi)
			_domain.axpyin(res[j], u[i], M[startMi]);
	}
}



template<class Domain>
void MatrixDom<Domain,Dense>::mul
( Rep& R, const Type_t& val, const Rep& A) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	_supportdomain.mul(R, val, A);
}

template<class Domain>
void MatrixDom<Domain,Dense>::mul
( Rep& R, const Rep& A, const Type_t& val) const
{
	GIVARO_ASSERT((ncol(R) == ncol(A)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(A)), "Bad size");
	_supportdomain.mul(R, A, val);
}

// r <- a*x+y
template<class Domain>
void MatrixDom<Domain,Dense>::axpy
( Rep& R, const Type_t& a, const Rep& X, const Rep& Y ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(X)) && (ncol(X) == ncol(Y)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(X)) && (nrow(X) == nrow(Y)), "Bad size");
	_supportdomain.axpy(R, a, X, Y);
}
// r <- r+a*x
template<class Domain>
void MatrixDom<Domain,Dense>::axpyin
( Rep& R, const Type_t& a, const Rep& X ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(X)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(X)), "Bad size");
	_supportdomain.axpyin(R, a, X);
}
// r <- a*x-y
template<class Domain>
void MatrixDom<Domain,Dense>::axmy ( Rep& R,
				     const Type_t& a, const Rep& X, const Rep& Y ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(X)) && (ncol(X) == ncol(Y)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(X)) && (nrow(X) == nrow(Y)), "Bad size");
	_supportdomain.axmy(R, a, X, Y);
}
// r <- a*x-r
template<class Domain>
void MatrixDom<Domain,Dense>::axmyin ( Rep& R,
				       const Type_t& a, const Type_t& X ) const
{
	GIVARO_ASSERT((ncol(R) == ncol(X)), "Bad size");
	GIVARO_ASSERT((nrow(R) == nrow(X)), "Bad size");
	_supportdomain.axmy(R, a, X);
}


// -- axpy operations:
// A*X + Y
template<class Domain>
void MatrixDom<Domain,Dense>::axpy
( Rep& R, const Rep& A, const Rep& X, const Rep& Y ) const
{
	int k, i, j;
	int startAi, startXj, startRi;
	int nrR = nrow(R);
	int ncR = ncol(R);
	int ncA = ncol(A);

	// -- the algorithm used the fact that matrices are stored by row
	Type_t tmp;
	for (i=0; i < nrR; ++i)
	{
		startRi = i*ncR;
		for (j=0; j < ncR; ++j, ++startRi)
		{
			startAi = i*ncA; startXj = j;
			_domain.assign(tmp, _domain.zero);
			for (k=0; k<ncA; ++k, ++startAi, startXj+=ncR) // ncR = ncX
				_domain.axpy(tmp, A[startAi], X[startXj], tmp);
			_domain.add( R[startRi], tmp, Y[startRi] );
		}
	}
}

// a*A*X - b*Y
template<class Domain>
void MatrixDom<Domain,Dense>::axpy
( Rep& res, const Type_t& a, const Rep& A,
  const Rep& X, const Type_t& b, const Rep& Y ) const
{
	Indice_t k, i, j;
	int startAi, startXj, startRi;
	Indice_t nrR = nrow(R);
	Indice_t ncR = ncol(R);
	Indice_t ncA = ncol(A);

	// -- the algorithm used the fact that matrices are stored by row
	Type_t tmp;
	for (i=0; i < nrR; ++i)
	{
		startRi = i*ncR;
		for (j=0; j < ncR; ++j, ++startRi)
		{
			startAi = i*ncA; startXj = j;
			_domain.assign(tmp, _domain.zero);
			for (k=0; k<ncA; ++k, ++startAi, startXj+=ncR) // ncR = ncX
				_domain.axpy(tmp, A[startAi], X[startXj], tmp);
			_domain.mul( tmp, a, tmp );
			_domain.axpy( R[startRi], b, Y[startRi], tmp);
		}
	}
}

// Map: used for constant operation !, not that OP
template<class Domain>
template<class OP>
void MatrixDom<Domain,Dense>::map
( Rep& R, OP& op ) const
{
	Indice_t i;
	Indice_t max = _supportdomain.dim(R);
	for (i=max; --i>=0; ) op(R[i]);
}

template<class Domain>
template<class OP>
void MatrixDom<Domain,Dense>::map
( Rep& R, OP& op, const Rep& A ) const
{
	Indice_t i;
	Indice_t max = _supportdomain.dim(R);
	for (i=max; --i>=0; ) op(R[i], A[i]);
}

template<class Domain>
template<class OP>
void MatrixDom<Domain,Dense>::map
( Rep& R, OP& op, const Rep& A, const Rep& B ) const
{
	Indice_t i;
	Indice_t max = _supportdomain.dim(R);
	for (i=max; --i>=0; ) op(R[i], A[i], B[i]);
}


template <class Domain>
inline ostream& MatrixDom<Domain,Dense>::write( ostream& sout ) const
{
	return _domain.write(sout << '(') << ",Dense)";
}


// -- read the domain
template<class Domain>
istream& MatrixDom<Domain,Dense>::read( istream& sin )
{
	char ch;
	sin >> std::ws >> ch;
	if (ch != '(')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no '('"));

	// -- read subdomain:
	_domain.read(sin);

	// -- read ,
	sin >> std::ws >> ch;
	if (ch != ',')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ','"));

	// -- read dense:
	char name[6];
	sin >> std::ws; sin.read(name, 5); name[5] = (char)0;
	if (strcmp(name, "Dense") !=0)
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no 'Dense'"));

	// -- read )
	sin >> std::ws >> ch;
	if (ch != ')')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ')'"));
	return sin;
}


template <class Domain>
ostream& MatrixDom<Domain,Dense>::write( ostream& sout, const Rep& A) const
{
	int i,j;
	sout << '[' << nrow(A) << ',' << ncol(A) << ",[";
	for (i=0; i < nrow(A); i++)
	{
		sout << "[";
		for (j=0; j < ncol(A); j++)
		{
			_domain.write(sout,A(i,j));
			if (j < ncol(A) - 1) sout << ",";
		}
		if (i < nrow(A) - 1) sout << "]," << endl;
		else sout << "]";
	}
	return sout << "]]";
}

template <class Domain>
istream& MatrixDom<Domain,Dense>::read (istream& sin, Rep& R) const
{
	char ch;
	Indice_t i,j;
	long nr,nc;

	//  -- read [
	sin >> std::ws >> ch;
	if (ch != '[') {
		cerr << "Read: " << ch << endl;
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no '['"));
	}

	// -- read dimensions: nr , nc
	// -- read nrow
	sin >> std::ws >> nr;
	if (nr < 0)
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: bad row dimension"));

	//  -- read ,
	sin >> std::ws >> ch;
	if (ch != ',')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ','"));

	//  -- read ncol
	sin >> std::ws >> nc;
	if (nc < 0)
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: bad col dimension"));

	//  -- read ,
	sin >> std::ws >> ch;
	if (ch != ',')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ','"));

	//  -- read [
	sin >> std::ws >> ch;
	if (ch != '[')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no '[' before entries"));

	// -- Read the matrix:
	R.reallocate( nr, nc );
	for (i=0; i<nr; ++i) {
		if (i != 0) {
			sin >> std::ws >> ch;
			if (ch != ',')
				GivError::throw_error(
						      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ','"));
		}

		cout << "Row: " << i << endl;
		//  -- read [
		sin >> std::ws >> ch;
		if (ch != '[')
			GivError::throw_error(
					      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no '['"));

		// read nc-1 times: val ,
		for (j=0; j< nc-1; ++j) {
			cout << "Read: i=" << i << ", j=" << j << endl;
			_domain.read(sin, R(i,j));
			//  -- read [
			sin >> std::ws >> ch;
			if (ch != ',')
				GivError::throw_error(
						      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ','"));
		}

		// read 1 : val ]
		cout << "Read: i=" << i << ", j=" << j << endl;
		_domain.read(sin, R(i,j));
		sin >> std::ws >> ch;
		if (ch != ']')
			GivError::throw_error(
					      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ']'"));
	}

	//  -- read ] ]
	sin >> std::ws >> ch;
	if (ch != ']')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ']'"));
	sin >> std::ws >> ch;
	if (ch != ']')
		GivError::throw_error(
				      GivBadFormat("MatrixDom<Domain,Dense>::read: syntax error no ']'"));
	return sin;
}
} // Givaro

//#include "givaro/givmatdenseops.f.spe"
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s