This file is indexed.

/usr/include/fflas-ffpack/field/field-traits.h 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
/* -*- 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 Clement Pernet <Clement.Pernet@imag.fr>
 * 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 field/field-traits.h
 * @brief  Field Traits
 */

#ifndef __FFLASFFPACK_field_field_traits_H
#define __FFLASFFPACK_field_field_traits_H

#include <type_traits> // CXX11
#include "fflas-ffpack/field/rns-double-elt.h"

// ----- Forward declarations

#include "recint/rmint.h"
#include "givaro/modular-general.h"
#include "givaro/zring.h"

namespace RecInt {
	
	template<size_t K>
	class rint;
	
	template<size_t K>
	class ruint;

}

namespace Givaro {

	template<class T>
	class ModularBalanced;

	template<class T>
	class Montgomery;

}

namespace FFPACK {

	template<class T>
	class RNSInteger;

	template<class T>
	class RNSIntegerMod;

}

namespace FFLAS { /*  Categories */

	//! Traits and categories will need to be placed in a proper file later

	namespace FieldCategories {
	
		    // Classify
		//! generic ring.
		struct GenericTag{};
		//! This is a modular field like e.g. <code>Modular<T></code> or <code>ModularBalanced<T></code>
		struct ModularTag{};
		//! If the field uses a representation with infix operators
		struct UnparametricTag{};
	}

	    //! Specifies the mode of action for an algorithm w.r.t. its field
	    //! 
	namespace ModeCategories {
		    //! No specific mode of action: use standard field operations
		struct DefaultTag{};

		    //! Use standard field operations, but keeps track of bounds on input and output
		struct DefaultBoundedTag{};

		    //! Force conversion to appropriate element type of ElementCategory T.
		    //! e.g. 
		    //!    - ConvertTo<ElementCategories::MachineFloatTag> tries conversion 
		    //!      of Modular<int> to Modular<double>
		    //!    - ConvertTo<ElementCategories::FixedPrecIntTag> tries conversion 
                    //!      of Modular<Integer> to Modular<RecInt<K> >
		    //!    - ConvertTo<ElementCategories::ArbitraryPrecIntTag> tries conversion 
		    //!     of Modular<Integer> to RNSInteger
		    //! .
		template<class T>
		struct ConvertTo{};

		    //! Performs field operations with delayed mod reductions. Ensures result is reduced.
		struct DelayedTag{};

		    //! Performs field operations with delayed mod only when necessary. Result may not be reduced.
		struct LazyTag{};
	}

	namespace ElementCategories {
		    //! default is generic
		struct GenericTag{};
		    //! float or double
		struct MachineFloatTag{};
		    //! short, int, long, long long, and unsigned variants
		struct MachineIntTag{};
		    //! Fixed precision integers above machine precision: Givaro::recInt
		struct FixedPrecIntTag{};
		    //! Arbitrary precision integers: GMP
		struct ArbitraryPrecIntTag{};
		    //! Representation in a Residue Number System 
		struct RNSElementTag{};
		//- If it can support SIMD operations (ie \c double or \c int32_t, etc)
		// struct SIMDTag : public GenericTag{};
	}

} // FFLAS

namespace FFLAS { /*  Traits */

	/*! ElementTraits
	*/
	template <class Element>
	struct ElementTraits {typedef typename ElementCategories::GenericTag value;};
	
	template<> struct ElementTraits<float> {typedef ElementCategories::MachineFloatTag value;};
	template<> struct ElementTraits<double> {typedef ElementCategories::MachineFloatTag value;};
	template<> struct ElementTraits<int8_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<int16_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<int32_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<int64_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<uint8_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<uint16_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<uint32_t> {typedef ElementCategories::MachineIntTag value;};
	template<> struct ElementTraits<uint64_t> {typedef ElementCategories::MachineIntTag value;};
	template<>
	struct ElementTraits<Givaro::Integer> {typedef ElementCategories::ArbitraryPrecIntTag value;};
	template<size_t K> 
	struct ElementTraits<RecInt::rint<K> > {typedef ElementCategories::FixedPrecIntTag value;};
	template<size_t K> 
	struct ElementTraits<RecInt::ruint<K> > {typedef ElementCategories::FixedPrecIntTag value;};
	template<size_t K, int MG> 
	struct ElementTraits<RecInt::rmint<K, MG> >{typedef ElementCategories::FixedPrecIntTag value;};
	template<>
	struct ElementTraits<FFPACK::rns_double_elt>{typedef ElementCategories::RNSElementTag value;};


	/*! ModeTraits
	*/
	template <class Field> 
	struct ModeTraits {typedef typename ModeCategories::DefaultTag value;};

	template <typename Element, typename Compute> 
	struct ModeTraits<Givaro::Modular<Element,Compute> >{typedef typename ModeCategories::DelayedTag value;};

	template<typename Compute> struct ModeTraits<Givaro::Modular<int8_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template<typename Compute> struct ModeTraits<Givaro::Modular<int16_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template<typename Compute> struct ModeTraits<Givaro::Modular<int32_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template<typename Compute> struct ModeTraits<Givaro::Modular<uint8_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template<typename Compute> struct ModeTraits<Givaro::Modular<uint16_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template<typename Compute> struct ModeTraits<Givaro::Modular<uint32_t,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};

#ifndef INTEGER_NO_RNS
	template<typename Compute> struct ModeTraits<Givaro::Modular<Givaro::Integer,Compute> > {typedef typename ModeCategories::ConvertTo<ElementCategories::RNSElementTag> value;};
#endif

	template <typename Element>
	struct ModeTraits<Givaro::ModularBalanced<Element> >{typedef typename ModeCategories::DelayedTag value;};
	
	template <> struct ModeTraits<Givaro::ModularBalanced<int8_t> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template <> struct ModeTraits<Givaro::ModularBalanced<int16_t> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};
	template <> struct ModeTraits<Givaro::ModularBalanced<int32_t> > {typedef typename ModeCategories::ConvertTo<ElementCategories::MachineFloatTag> value;};

#ifndef INTEGER_NO_RNS
	template <> struct ModeTraits<Givaro::ModularBalanced<Givaro::Integer> > {typedef typename ModeCategories::ConvertTo<ElementCategories::RNSElementTag> value;};
	template <> struct ModeTraits<Givaro::ZRing<Givaro::Integer> > {typedef typename ModeCategories::ConvertTo<ElementCategories::RNSElementTag> value;};
#endif

	    // These ones are here temporarily, to ensure
	    // In the long term ZRing should be in DefaultTag, and forced to be in DefaultBoundedTag be the caller. However this would prevent these rings to use Winograd's algorithm (extensive use of bounded helpers) in the current implementation. Needs work.
	template <> struct ModeTraits<Givaro::ZRing<float> > {typedef typename ModeCategories::DefaultBoundedTag value;};
	template <> struct ModeTraits<Givaro::ZRing<double> > {typedef typename ModeCategories::DefaultBoundedTag value;};
	template <class T> struct ModeTraits<Givaro::Montgomery<T> > {typedef typename ModeCategories::DefaultBoundedTag value;};

	/*! FieldTrait
	*/
	template <class Field>
	struct FieldTraits {
		typedef typename FieldCategories::GenericTag category;
		// typedef false_type balanced ;
		static  const bool balanced = false ;
	};
	

	// RecInt
	template<size_t K>
	struct FieldTraits<Givaro::ZRing<RecInt::ruint<K> > > {
		    //typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	
        // Modular <double|float>
	// ModularBalanced <double|float>
	template<class Element>
	struct FieldTraits<Givaro::Modular<Element> > {
		typedef FieldCategories::ModularTag category;
		static  const bool balanced = false ;
	};

	template<class Element>
	struct FieldTraits<Givaro::ModularBalanced<Element> > {
		typedef FieldCategories::ModularTag category;
		static  const bool balanced = true ;
	};

	// ZRing< float|double >
	template<>
	struct FieldTraits<Givaro::ZRing<double> > {
//		typedef FieldCategories::FloatingPointTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<float> > {
//		typedef FieldCategories::FloatingPointTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};

	// ZRing< intX >
	template<>
	struct FieldTraits<Givaro::ZRing<int16_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<uint16_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<int32_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<uint32_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<int64_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	template<>
	struct FieldTraits<Givaro::ZRing<uint64_t> > {
//		typedef FieldCategories::FloatingPointConvertibleTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};
	
	// ZRing<Integer>
	template<>
	struct FieldTraits<Givaro::ZRing<Givaro::Integer> >
	{
//		typedef FieldCategories::MultiPrecisionTag value;
		typedef FieldCategories::UnparametricTag category;
		static  const bool balanced = false ;
	};

	// RNSInteger
	template<typename T>
	struct FieldTraits<FFPACK::RNSInteger<T> > {
//		typedef FieldCategories::MultiPrecisionTag value;
		typedef FieldCategories::UnparametricTag category;
		// typedef true_type balanced ;
		static  const bool balanced = false ;
	};
	// RNSIntegerMod
	template<typename T>
	struct FieldTraits<FFPACK::RNSIntegerMod<T> >{
//		typedef FieldCategories::MultiPrecisionTag value;
		typedef FieldCategories::ModularTag category;
		// typedef true_type balanced ;
		static  const bool balanced = false ;
	};


} // FFLAS

namespace FFLAS { /* associatedDelayedField */

	template <class Field>
	struct associatedDelayedField{
		typedef Field field;
		typedef Field& type; // reference to avoid copying heavy fields
	};
	template <typename T,typename X>
	struct associatedDelayedField<const Givaro::Modular<T,X>> {
		typedef Givaro::ZRing<T> field;
		typedef Givaro::ZRing<T> type;
	};
	template <typename T>
	struct associatedDelayedField<const Givaro::ModularBalanced<T>> {
		typedef Givaro::ZRing<T> field;
		typedef Givaro::ZRing<T> type;
	};
	template <typename T>
	struct associatedDelayedField<const Givaro::ZRing<T>> {
		typedef Givaro::ZRing<T> field;
		typedef Givaro::ZRing<T> type;
	};
	template <typename RNS>
	struct associatedDelayedField<const FFPACK::RNSIntegerMod<RNS>> {
		typedef FFPACK::RNSInteger<RNS> field;
		typedef FFPACK::RNSInteger<RNS> type;
	};
	
} // FFLAS

#endif // __FFLASFFPACK_field_field_traits_H