This file is indexed.

/usr/include/fflas-ffpack/fflas/fflas_level1.inl is in fflas-ffpack-common 2.2.2-5.

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
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/*
 * Copyright (C) 2014 the FFLAS-FFPACK group
 *
 * Written by Brice Boyer (briceboyer) <boyer.brice@gmail.com>
 *
 *
 * ========LICENCE========
 * This file is part of the library FFLAS-FFPACK.
 *
 * FFLAS-FFPACK 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 fflas/fflas_level1.h
 * @brief  Vector operations
 * or anything of \f$n\f$ complexity
 */

#ifndef __FFLASFFPACK_fflas_fflas_level1_INL
#define __FFLASFFPACK_fflas_fflas_level1_INL

namespace FFLAS {



	//---------------------------------------------------------------------
	// Level 1 routines
	//---------------------------------------------------------------------

	/** freduce
	 * \f$x \gets  x mod F\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field>
	void
	freduce (const Field& F, const size_t n,
		 typename Field::Element_ptr X, const size_t incX);

	/** freduce
	 * \f$x \gets  y mod F\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param Y vector of \p Element
	 * \param incY stride of \p Y
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field>
	void
	freduce (const Field& F, const size_t n,
		 typename Field::ConstElement_ptr Y, const size_t incY,
		 typename Field::Element_ptr X, const size_t incX);

	/** finit
	 * \f$x \gets  y mod F\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param Y vector of \p OtherElement
	 * \param incY stride of \p Y
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field, class OtherElement_ptr>
	void
	finit (const Field& F, const size_t n,
	       const OtherElement_ptr Y, const size_t incY,
	       typename Field::Element_ptr X, const size_t incX);

	/** fconvert
	 * \f$x \gets  y mod F\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param Y vector of \p F
	 * \param incY stride of \p Y
	 * \param X vector in \p OtherElement
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field, class OtherElement_ptr>
	void
	fconvert (const Field& F, const size_t n,
		  OtherElement_ptr X, const size_t incX,
		  typename Field::ConstElement_ptr Y, const size_t incY)
	{
		OtherElement_ptr Xi = X ;
		typename Field::ConstElement_ptr Yi = Y ;
		for (; Xi < X+n*incX; Xi+=incX, Yi += incY )
			F.convert( *Xi , *Yi);
	}

	/** fnegin
	 * \f$x \gets - x\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field>
	void
	fnegin (const Field& F, const size_t n,
		typename Field::Element_ptr X, const size_t incX)
	{
		typename Field::Element_ptr Xi = X ;
		for (; Xi < X+n*incX; Xi+=incX )
			F.negin( *Xi );
	}

	/** fneg
	 * \f$x \gets - y\f$.
	 * @param F field
	 * @param n size of the vectors
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * \param Y vector in \p F
	 * \param incY stride of \p Y
	 * @bug use cblas_(d)scal when possible
	 */
	template<class Field>
	void
	fneg (const Field& F, const size_t n,
	      typename Field::ConstElement_ptr Y, const size_t incY,
	      typename Field::Element_ptr X, const size_t incX)
	{
		typename Field::Element_ptr Xi = X ;
		typename Field::ConstElement_ptr Yi = Y ;
		for (; Xi < X+n*incX; Xi+=incX,Yi+=incY  )
			F.neg( *Xi, *Yi );
	}

	/** \brief fzero : \f$A \gets 0 \f$.
	 * @param F field
	 * @param n number of elements to zero
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 */
	template<class Field>
	void
	fzero (const Field& F, const size_t n,
	       typename Field::Element_ptr X, const size_t incX)
	{
		if (incX == 1) { // contigous data
			// memset(X,(int)F.zero,n); // might be bogus ?
			for (size_t i = 0 ; i < n ; ++i)
				F.assign(*(X+i), F.zero);

		}
		else { // not contiguous (strided)
			for (size_t i = 0 ; i < n ; ++i)
				F.assign(*(X+i*incX), F.zero);
		}
	}

	/** \brief frand : \f$A \gets random \f$.
	 * @param F field
	 * @param G randomiterator
	 * @param n number of elements to randomize
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 */
	template<class Field, class RandIter>
	void
	frand (const Field& F, RandIter& G, const size_t n,
	       typename Field::Element_ptr X, const size_t incX)
	{
		if (incX == 1) { // contigous data
			// memset(X,(int)F.zero,n); // might be bogus ?
			for (size_t i = 0 ; i < n ; ++i)
				G.random(*(X+i));

		}
		else { // not contiguous (strided)
			for (size_t i = 0 ; i < n ; ++i)
				G.random(*(X+i*incX));
		}
	}
	
       /** \brief fiszero : test \f$X = 0 \f$.
	 * @param F field
	 * @param n vector dimension
	 * \param X vector in \p F
	 * \param incX increment of \p X
	 */
	template<class Field>
	bool
	fiszero (const Field& F, const size_t n,
		 typename Field::ConstElement_ptr X, const size_t incX)
	{
		bool res=true;
		for (size_t i = 0 ; i < n ; ++i)
			res &= F.isZero (X [i*incX]);
		return res;
	}

       /** \brief fequal : test \f$X = Y \f$.
	 * @param F field
	 * @param n vector dimension
	 * \param X vector in \p F
	 * \param incX increment of \p X
	 * \param Y vector in \p F
	 * \param incY increment of \p Y
	 */
	template<class Field>
	bool
	fequal (const Field& F, const size_t n,
		typename Field::ConstElement_ptr X, const size_t incX,
		typename Field::ConstElement_ptr Y, const size_t incY)
	{
		bool res=true;
		for (size_t i = 0 ; i < n ; ++i)
			res &= F.areEqual (X [i*incX], Y [i*incY]);
		return res;
	}

	/** \brief fassign : \f$x \gets y \f$.
	 * X is preallocated
	 * @todo variant for triagular matrix
	 * @param F field
	 * @param N size of the vectors
	 * \param [out] X vector in \p F
	 * \param incX stride of \p X
	 * \param [in] Y vector in \p F
	 * \param incY stride of \p Y
	 */
	template<class Field>
	void
	fassign (const Field& F, const size_t N,
	       typename Field::ConstElement_ptr Y, const size_t incY ,
	       typename Field::Element_ptr X, const size_t incX);


	/** fscalin
	 * \f$x \gets \alpha \cdot x\f$.
	 * @param F field
	 * @param n size of the vectors
	 * @param alpha scalar
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * @bug use cblas_(d)scal when possible
	 * @internal
	 * @todo check if comparison with +/-1,0 is necessary.
	 */
	template<class Field>
	void
	fscalin (const Field& F, const size_t n, const typename Field::Element alpha,
		 typename Field::Element_ptr X, const size_t incX);


	/** fscal
	 * \f$y \gets \alpha \cdot x\f$.
	 * @param F field
	 * @param n size of the vectors
	 * @param alpha scalar
	 * \param[in] X vector in \p F
	 * \param incX stride of \p X
	 * \param[out] Y vector in \p F
	 * \param incY stride of \p Y
	 * @bug use cblas_(d)scal when possible
	 * @internal
	 * @todo check if comparison with +/-1,0 is necessary.
	 */
	template<class Field>
	void
	fscal (const Field& F, const size_t n
	       , const typename Field::Element alpha
	       , typename Field::ConstElement_ptr X, const size_t incX
	       , typename Field::Element_ptr Y, const size_t incY);



	/** \brief faxpy : \f$y \gets \alpha \cdot x + y\f$.
	 * @param F field
	 * @param N size of the vectors
	 * @param alpha scalar
	 * \param[in] X vector in \p F
	 * \param incX stride of \p X
	 * \param[in,out] Y vector in \p F
	 * \param incY stride of \p Y
	 */
	template<class Field>
	void
	faxpy (const Field& F, const size_t N,
	       const typename Field::Element alpha,
	       typename Field::ConstElement_ptr X, const size_t incX,
	       typename Field::Element_ptr Y, const size_t incY );

	/** \brief faxpby : \f$y \gets \alpha \cdot x + \beta \cdot y\f$.
	 * @param F field
	 * @param N size of the vectors
	 * @param alpha scalar
	 * \param[in] X vector in \p F
	 * \param incX stride of \p X
	 * \param beta scalar
	 * \param[in,out] Y vector in \p F
	 * \param incY stride of \p Y
	 * \note this is a catlas function
	 */
	template<class Field>
	void
	faxpby (const Field& F, const size_t N,
		const typename Field::Element alpha,
		typename Field::ConstElement_ptr X, const size_t incX,
		const typename Field::Element beta,
		typename Field::Element_ptr Y, const size_t incY );


	/** \brief fdot: dot product \f$x^T  y\f$.
	 * @param F field
	 * @param N size of the vectors
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * \param Y vector in \p F
	 * \param incY stride of \p Y
	 */
	template<class Field>
	typename Field::Element
	fdot (const Field& F, const size_t N,
	      typename Field::ConstElement_ptr X, const size_t incX,
	      typename Field::ConstElement_ptr Y, const size_t incY );

	/** \brief fswap: \f$ X \leftrightarrow Y\f$.
	 * @bug use cblas_dswap when double
	 * @param F field
	 * @param N size of the vectors
	 * \param X vector in \p F
	 * \param incX stride of \p X
	 * \param Y vector in \p F
	 * \param incY stride of \p Y
	 */
	template<class Field>
	void
	fswap (const Field& F, const size_t N, typename Field::Element_ptr X, const size_t incX,
	       typename Field::Element_ptr Y, const size_t incY )
	{

		typename Field::Element tmp; F.init(tmp);
		typename Field::Element_ptr Xi = X;
		typename Field::Element_ptr Yi=Y;
		for (; Xi < X+N*incX; Xi+=incX, Yi+=incY ){
			F.assign( tmp, *Xi );
			F.assign( *Xi, *Yi );
			F.assign( *Yi, tmp );
		}
	}

	template <class Field>
        void
        pfadd (const Field & F,  const size_t M, const size_t N,
               typename Field::ConstElement_ptr A, const size_t lda,
               typename Field::ConstElement_ptr B, const size_t ldb,
               typename Field::Element_ptr C, const size_t ldc, const size_t numths);

	template <class Field>
        void
        pfsub (const Field & F,  const size_t M, const size_t N,
               typename Field::ConstElement_ptr A, const size_t lda,
               typename Field::ConstElement_ptr B, const size_t ldb,
               typename Field::Element_ptr C, const size_t ldc, const size_t numths);
	
	template <class Field>
        void
        pfaddin (const Field& F, const size_t M, const size_t N,
		 typename Field::ConstElement_ptr B, const size_t ldb,
                 typename Field::Element_ptr C, const size_t ldc, size_t numths);
	
	template <class Field>
        void
        pfsubin (const Field& F, const size_t M, const size_t N,
		 typename Field::ConstElement_ptr B, const size_t ldb,
                 typename Field::Element_ptr C, const size_t ldc, size_t numths);
	
	
	template <class Field>
	void
	fadd (const Field& F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc);

	template <class Field>
	void
	fsub (const Field& F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc);

	template <class Field>
	void
	faddin (const Field& F,  const size_t N,
		typename Field::ConstElement_ptr B, const size_t incb,
		typename Field::Element_ptr C, const size_t incc);

	template <class Field>
	void
	fsubin (const Field& F,  const size_t N,
		typename Field::ConstElement_ptr B, const size_t incb,
		typename Field::Element_ptr C, const size_t incc);


	template <class Field>
	void
	fadd (const Field& F,  const size_t N,
	      typename Field::ConstElement_ptr A, const size_t inca,
	      const typename Field::Element alpha,
	      typename Field::ConstElement_ptr B, const size_t incb,
	      typename Field::Element_ptr C, const size_t incc);

} // FFLAS


#endif // __FFLASFFPACK_fflas_fflas_level1_INL