This file is indexed.

/usr/include/linbox/field/local2_32.h is in liblinbox-dev 1.1.6~rc0-4.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
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* linbox/field/local2_32.h
 * written by bds, wan
 *
 */

#ifndef __LOCAL2_32_H
#define __LOCAL2_32_H

#include "linbox/field/unparametric.h"
#include "linbox/util/debug.h"
#include "linbox/linbox-config.h"
#include <linbox/field/field-traits.h>
#include <linbox/integer.h>
#include <linbox/field/field-traits.h>

namespace LinBox
{
  
        template<typename Ring>
	struct ClassifyRing;

	class Local2_32;

	template<>
	struct ClassifyRing<Local2_32> {
		typedef RingCategories::ModularTag categoryTag;
	};

	/** \brief Fast arithmetic mod 2^32, including gcd.
	 *
	 * Extend UnparametricField<uint32> which is a representation 
	 * of Z_2^32. It is especially fast because it uses hardware arithmetic 
	 * directly.  This ring is a Local Principal Ideal Ring.
	 *
	 * These needed PIR functions are added:
	 * gcdin(), isUnit(), also inv() is modified to work correctly.
	 * The type Exponent is added: more effective rep of the powers of 2, 
	 * which are important because gcds are powers of 2).  
	 * This entails some new versions of divin(), mulin(), isUnit().
	 *
	 * Those are the function needed for the LocalSmith algorithm.
	 * Further appropriate PIR functions may be added later.
	 * \ingroup field
	 */

	struct Local2_32: public UnparametricField<uint32>
	{
	public:

		typedef UnparametricField<uint32>::Element Element;
		typedef enum {_min=0,_max=32} Exponent; // enum?
		//Exponent& init(Exponent& a) { return a = 32; }
			
		Local2_32 (int p=2, int exp=32) :UnparametricField<uint32>(p,exp) {
			if(p != 2) throw PreconditionFailed(__FUNCTION__,__LINE__,"modulus must be 2");
			if(exp != 32) throw PreconditionFailed(__FUNCTION__,__LINE__,"exponent must be 32");
		}

		/*
		static inline Element& gcd(Element& c, Element& a, const Element& b)
		{   c = a | b; Exponent k = 0; 
		    while (! (c & 1)) {c >>= 1; ++k;}
		    //gcdin (k, b);
		    cout << "gcd called" << endl;
		    return c = 1 << k;
		}

		*/
		// assume k is an exponent of 2.
		static inline Exponent& gcdin(Exponent& k, const Element& b)
		{   /*
		      Element c = b >> k;
		      c <<= k;
		      Element d = b;
		      std::cout << "c, b" << c << " " << b <<  "\n";
		      if (c != b)  for(k = 0; ! (d & 1); ++k) d >>= 1; 
		      std::cout << "g, b =" << (int)k << " " << b << "\n";
		    */
			Element d = b;
			int i;
			for ( i = 0; (i < k) && (!(d&1)); ++ i) d >>= 1;
			return k = Exponent(i);
		}

		static inline bool isUnit(const Exponent& a)
		{   return a == 0;   }

		static inline bool isZero(const Element& a)
		{   return a == 0;   }

		static inline bool isZero(const Exponent& a)
		{   return a >= 32;   }

		// not used ...
		static inline bool isUnit(const Element& a)
		{   return a & 1;   }

		//Element& div(Element& c, const Element& a, const Element& b) const
		//{   return c = NTL::rep(a)/NTL::GCD(NTL::rep(a),NTL::rep(b));   }
		//
		
		static inline Element& mulin(Element& a, const Exponent& k) 
		{  
			if (k >= 32) return a = 0;
			else return a <<= k;  
		}

		static inline Element& mulin(Element& a, const Element& b)  {
			return a *= b;
		}

		static inline Element& axpyin(Element& r, const Element& x, const Element& y) {
			return r += x * y;
		}

		/*
		static inline bool isDivisor(Element a, Element b)
		{   while (! (a ^ 1)) 
		    {   if (b ^ 1) return false;
		        a = a >> 1; b = b >> 1;
		    }
		    return true;
		}
		*/

		// assume k is an exponent of 2 and the power of 2 exactly divides a
		static inline Element& divin(Element& a, const Exponent& k)
		{   return a >>= k;   }

		static inline Element& inv(Element& a, const Element& b) {

			if (!isUnit(b))
				throw PreconditionFailed(__FUNCTION__,__LINE__,"inv: not a unit");
			else {

				Element g, s, t;
				
				xgcd(g, s, t, b, -b);
				
				return a = s - t;
			}
		}

                static inline integer getMaxModulus()
                        { return integer( "4294967296" ); } // 2^32

	protected:
		
		static  Element& xgcd(Element& d, Element& s, Element& t, const Element& a, const Element& b) 
		{
		       
			Element  u, v, u0, v0, u1, v1, u2, v2, q, r;
			
			u1 = 1; v1 = 0;
			u2 = 0; v2 = 1;
			u = a; v = b;
		    
			while (v != 0) {
				q = u / v;
				//r = u % v;
				r = u - q*v;
				u = v;
				v = r;
				u0 = u2;
				v0 = v2;
				u2 =  u1 - q*u2;
				v2 = v1- q*v2;
				u1 = u0;
				v1 = v0;
			}
		    
		    
			d = u;
			s = u1;
			t = v1;
			//std::cout << "XGCD is called: d, s, t, a, b, sa + tb: " << d << ' '
			//	<< s << ' ' << t << ' ' << a << ' ' << b << ' ' << s * a + t * b << '\n';
			return d;

			/*

			//Element  u, v, u0, v0, u1, v1, u2, v2, q, r;
			
			Element u, v, q, r;
			
			int64  u0, u1, u2;
			
			u1 = 1; //v1 = 0;
			u2 = 0; //v2 = 1;
			u = a; v = b;
		    
			if ( b == 0) {
				s = 1;
				t = 0;
				return d = a ;
			}
			
			if (v != 0) {
				q = u / v;
				//r = u % v;
				r = u - q*v;
				u = v;
				v = r;
				u0 = u2;
				//v0 = v2;
				u2 =  u1 - q * u2;
				//v2 = v1- q * v2;
				u1 = u0;
				//v1 = v0;
				
			}

			while (v != 0) {
				r = u;
				while ( r >= v) {
					r = u - v;
					
					u2 = u1 - u2;
				}
				u0 = u2;
				u1 = u0;
				u = v;
				v = r;
				
				
			}	
				
			
			while (v != 0) {
				q = u / v;
				//r = u % v;
				r = u - q*v;
				u = v;
				v = r;
				
				u0 = u2;
				//v0 = v2;
				u2 =  u1 - q * u2;
				//v2 = v1- q * v2;
				u1 = u0;
				//v1 = v0;
			}
			
		    
			d = u;
			s = u1;
			
			t = ((int64) d - u1 * (int64) a) / (int64)b;

			//std::cout << "XGCD is called: d, s, t, a, b, sa + tb: " << d << ' '
			//<< s << ' ' << t << ' ' << a << ' ' << b << ' ' << s * a + t * b << '\n';
			return d;
			
			
			*/
		}
		

		/** @brief 
		 * Half GCD
		 * g = gcd (a, b).
		 * exists t, such that: s * a + t * b = g.
		 * return g.
		 */
		static Element& HGCD (Element& g, Element& s, const Element& a, const  Element& b) {
			
			Element  u, v, u0, u1, u2, q, r;
			
			u1 = 1;
			u2 = 0;
			u = a; v = b;
		    
			while (v != 0) {
				q = u / v;
				//r = u % v;
				r = u - q*v;
				u = v;
				v = r;
				
				u0 = u2;
				
				u2 =  u1 - q*u2;
				
				u1 = u0;
				
			}
		    
		    
			g = u;
			s = u1;

			return g;	
	    
		}

	};

        template<>
	bool FieldTraits< Local2_32 >::goodModulus( const integer& i ) {
		return i == Local2_32::getMaxModulus();
	}
		
} // namespace LinBox

#endif // __LOCAL2_32_H