This file is indexed.

/usr/include/fflas-ffpack/ffpack/ffpack_charpoly_kglu.inl is in fflas-ffpack-common 1.6.0-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
/* -*- 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
//
#ifndef __FFLASFFPACK_ffpack_charpoly_kglu_INL
#define __FFLASFFPACK_ffpack_charpoly_kglu_INL

/* ffpack/ffpack_charpoly_kglu.inl
 * Copyright (C) 2005 Clement Pernet
 *
 * Written by Clement Pernet <Clement.Pernet@imag.fr>
 *
 * 
 * ========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========
 *.
 */

namespace FFPACK {

	namespace Protected {

		template<class Field>
		size_t updateD(const Field& F, size_t * d, size_t k,
			       std::vector<std::vector<typename Field::Element> >& minpt)
		{
			size_t ind=0, i=0;
			while(i<k){
				if (d[i]){
					if (ind<i){
						d[ind] = d[i];
						minpt[ind++] = minpt[i];
					}
					else ind++;
				}
				i++;
			}
			for (i=ind; i<k; ++i)
				minpt[i].resize(0);
			minpt.resize(ind);
			return ind;
		}

		// Compute the new d after a LSP ( d[i] can be zero )
		template<class Field>
		size_t newD( const Field& F, size_t * d, bool& KeepOn,
			     const size_t l, const size_t N,
			     typename Field::Element * X,
			     const size_t * Q,
			     std::vector<std::vector<typename Field::Element> >& minpt)
		{
			typedef typename Field::Element elt;
			//const elt * Xi = X; // Xi points to the begining of each block
			elt *Li=X, *Xminp=X;
			KeepOn = false;
			size_t nr, s, i, j, jtot=0, dtot = 0, nrtot=0;

			for ( i=0; dtot<N; ++i){ // for each block
				j = 0;
				nr = s = ( d[i]==l )? 2*l : d[i];
				if (s > N-dtot)
					s= N-dtot;
				nrtot += nr;

				while ( (Q[j+jtot] <nrtot) && (j+jtot<N) )
					j++;

				Xminp = X+Q[j+jtot-1]*N+jtot+j ;
				d[i] = j;
				jtot+=j;
				dtot += j;

				if (j<nr){
					minpt[i].resize(j);
					ftrsv( F, FFLAS::FflasLower, FFLAS::FflasTrans, FFLAS::FflasUnit,
					       j, Li, N, Xminp-j+N,1);
					elt* Xi = Xminp-j+N;
					for (size_t ii = 0; ii<j; ++ii, ++Xi)
						minpt[i][ii] = *Xi;
				}
				Li += nr*N+j;
				if ( j==2*l )
					KeepOn = true;
			} // Invariant: sum(d[i],i=0..k-1) = n

			return i;
		}


		//---------------------------------------------------------------------
		// CharPoly: Compute the characteristic polynomial of A using
		// Keller-Gehrig's algorithm
		//---------------------------------------------------------------------
		template <class Field, class Polynomial>
		std::list<Polynomial>&
		KellerGehrig( const Field& F, std::list<Polynomial>& charp, const size_t N,
			      const typename Field::Element * A, const size_t lda )
		{


			typedef typename Field::Element elt;
			const elt * Ai=A;
			elt * U = new elt[N*N];     // to store A^2^i
			elt * B = new elt[N*N];     // to store A^2^i
			elt * V = new elt[N*N];     // to store A^2^i.U
			elt * X = new elt[2*N*N];   // to compute the LSP factorization
			elt *Ui, *Uj, *Uk, *Ukp1, *Ukp1new, *Bi, *Vi, *Vk, *Xi=X, *Xj;
			size_t * P = new size_t[N]; // Column Permutation for LQUP
			size_t * Q = new size_t[2*N]; // Row Permutation for LQUP

			size_t * d= new size_t[N];   // dimensions of Vect(ei, Aei...)
			size_t * dv = new size_t[N];
			size_t * dold = new size_t[N]; // copy of d
			// vector of the opposite of the coefficient of computed minpolys
			std::vector< std::vector< elt > > m(N);
			typename Polynomial::iterator it;
			size_t i=0, l=1, j, k=N,  cpt, newRowNb, nrowX, ind;
			bool  KeepOn;

			for ( i=0; i<N; ++i)
				dv[i] = dold[i] = d[i] = 1;

			// Computing the first X: (e1; e1A^t; e2; e2A^t;...;en;enA^t)
			for ( i=0, Ui=U, Vi=V, Bi=B; i<N; ++i, Ai -= N*lda-1  ){
				for ( Xj=Xi, Uj=Ui; Xj<Xi+N; ++Xj, ++Uj){
					F.assign(*Xj, F.zero);
					F.assign(*Ui, F.zero);
				}
				F.assign(*(Ui+i), F.one);
				F.assign(*(Xi+i), F.one);
				while ( Xj<Xi+2*N) {
					*(Bi++) = *(Xj++) = *(Vi++) = *Ai;
					Ai+=lda;
				}
				Xi = Xj;
				Ui = Uj;
			}

			// step form elimination using LQUP factorization
			for ( i=0;i<N;++i)
				P[i]=0;
			for ( i=0;i<2*N;++i)
				Q[i]=0;
			LUdivine( F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, 2*N, N, X, N, P, Q, FfpackLQUP);

			k = Protected::newD( F,d, KeepOn, l, N, X, Q, m);

			while(KeepOn){ // Main loop, until each subspace dimension has been found
				// Updating U:
				Uk = U;
				// Firstly, removing extra rows
				for ( i = 0, cpt = 0; i<N; ++i){
					if (d[i] < dold[i]){
						Ukp1new = Uk + d[i]*N;  // new position of Uk+1
						Ukp1 = Uk + dold[i]*N; // first row of Uk+1
						Ui = Ukp1new;
						Uj = Ukp1;
						while ( Uj < U + N*N ){
							for ( j=N; j; --j)
								*(Ui++) = *(Uj++);
						}
						Uk = Ukp1new;
						dold[i] = d[i];
					}
					else {
						Uk += dold[i]*N;
					}
					cpt += d[i];
				}

				// Then inserting the duplicated blocks
				Uk = U;
				Vk = V;
				for ( i = 0; i<k; ++i){
					Ukp1 = Uk + dold[i]*N; // first row of Uk+1
					newRowNb = d[i] - dold[i];
					if ( newRowNb > 0){
						Ui = U+N*N-1; // last row of U
						Uj = U+(N-newRowNb)*N-1; // last row future pos
						while ( Uj > Ukp1-1){
							for ( j=N;j;--j)
								*(Ui--) = *(Uj--);// moving block
						}
						Uj++;
						Vi = Vk;
						while ( Uj < Ukp1+N*newRowNb ){
							for ( j=N;j;--j)
								*(Uj++) = *(Vi++);
						}
					}
					Uk = Uk + d[i]*N;
					Vk += dv[i]*N;
				}

				// max block size of X, U, V is l=2^i
				l*=2;
				// B = A^2^i
				fsquare( F, FFLAS::FflasNoTrans, N, F.one, B, N, F.zero, B, N );
				// V = U.B^t
				fgemm( F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans, N, N, N, F.one,
				       U, N, B, N, F.zero, V, N);
				// X = ( U1, V1, U2, V2, ... )
				Xi = X; Ui = U; Vi = V;
				ind=0; cpt=0; nrowX = 0;
				while ( Vi < V + N*N ){
					// Copying Uk
					for ( i = d[ind]; i; --i, nrowX++){
						for ( j = N; j; --j )
							*(Xi++) = *(Ui++);
					}
					// Copying Vk
					if ( d[ind] == l || ind==k-1 ){
						cpt+=2*d[ind];
						for ( i=d[ind]; i; i--, nrowX++)
							for ( j=N; j; j--)
								*(Xi++) = *(Vi++);
					}
					else{
						cpt += d[ind];
						Vi = Vi + N*d[ind];
					}
					ind++;
				}
				// removes factors of degree 0 in m
				k = Protected::updateD( F, d, k, m);

				for (i=0;i<k;++i)
					dv[i] = dold[i] = d[i];

				// step form elimination of X using LSP
				for ( i=0;i<N;++i)
					P[i]=0;
				for ( i=0;i<2*N;++i)
					Q[i]=0;
				LUdivine( F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, nrowX, N, X, N, P, Q, FfpackLQUP);

				// Recompute the degrees of the list factors
				k = Protected::newD(F, d, KeepOn, l, N, X,Q, m);
			}
			delete[] U;
			delete[] V;
			delete[] B;
			delete[] P;
			delete[] Q;
			delete[] dv;
			delete[] dold;

			k = Protected::updateD( F, d, k, m);
			// Constructing the CharPoly
			for ( i=0; i<k; ++i){
				Polynomial * minP = new Polynomial(d[i]+1);
				minP->operator[](d[i]) = F.one;
				it = minP->begin();
				for ( j=0; j<d[i]; ++j, it++)
					F.neg(*it, m[i][j]);
				charp.push_back( *minP );
			}
			delete[] X;
			delete[] d;
			return charp;
		}

	} // Protected
} // FFPACK

#endif // __FFLASFFPACK_ffpack_charpoly_kglu_INL