This file is indexed.

/usr/include/fflas-ffpack/ffpack/ffpack_rankprofiles.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
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/* ffpack_rankprofiles.inl
 * Copyright (C) 2015 FFLAS-FFACK group
 *
 * 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========
 *.
 */

#ifndef __FFLASFFPACK_ffpack_rank_profiles_INL
#define __FFLASFFPACK_ffpack_rank_profiles_INL

namespace FFPACK{
template <class Field>
inline size_t RowRankProfile (const Field& F, const size_t M, const size_t N,
							  typename Field::Element_ptr A, const size_t lda,
							  size_t* &rkprofile,
							  const FFPACK_LU_TAG LuTag){

	
	size_t *P = FFLAS::fflas_new<size_t>((LuTag==FfpackSlabRecursive)?N:M);
	size_t *Q = FFLAS::fflas_new<size_t>((LuTag==FfpackSlabRecursive)?M:N);
	size_t R;

	if (LuTag == FfpackSlabRecursive){
		R = LUdivine (F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, M, N, A, lda, P, Q);
		std::swap(P,Q);
	} else
		R = PLUQ (F, FFLAS::FflasNonUnit, M, N, A, lda, P, Q);
		
	rkprofile = FFLAS::fflas_new<size_t> (R);
	
	RankProfileFromLU (P, M, R, rkprofile, LuTag);
	
	FFLAS::fflas_delete (Q);
	FFLAS::fflas_delete (P);
	return R;
}
template <class Field>
inline size_t ColumnRankProfile (const Field& F, const size_t M, const size_t N,
								 typename Field::Element_ptr A, const size_t lda,
								 size_t* &rkprofile,
								 const FFPACK_LU_TAG LuTag){
	
	
	size_t *P = FFLAS::fflas_new<size_t>(M);
	size_t *Q = FFLAS::fflas_new<size_t>(N);
	size_t R;

	if (LuTag == FfpackSlabRecursive){
		R = LUdivine (F, FFLAS::FflasNonUnit, FFLAS::FflasTrans, M, N, A, lda, P, Q);
	} else
		R = PLUQ (F, FFLAS::FflasNonUnit, M, N, A, lda, P, Q);
		
	rkprofile = FFLAS::fflas_new<size_t> (R);
	
	RankProfileFromLU (Q, N, R, rkprofile, LuTag);
	
	FFLAS::fflas_delete (P);
	FFLAS::fflas_delete (Q);
	return R;
}

inline void RankProfileFromLU (const size_t* Q, const size_t N, const size_t R,
							   size_t* rkprofile, const FFPACK_LU_TAG LuTag){

	if (LuTag == FfpackSlabRecursive) 
		std::copy(Q, Q+R, rkprofile);
	else {
		size_t * RP = FFLAS::fflas_new<size_t>(N);
		for (size_t i=0;i < N; ++i)
			RP [i] = i;
		for (size_t i=0; i<N; ++i)
			if (Q[i] != i)
				std::swap (RP [i], RP [Q [i]]);

		std::copy(RP, RP+R, rkprofile);
		std::sort (rkprofile, rkprofile + R);
		FFLAS::fflas_delete(RP);
	}
}

inline size_t LeadingSubmatrixRankProfiles (const size_t M, const size_t N, const size_t R,
											const size_t LSm, const size_t LSn,
											const size_t* P, const size_t* Q,
											size_t* RRP, size_t* CRP){
	size_t LSr=0; // rank of the LSm x LSn leading submatrix

	size_t* MathP = FFLAS::fflas_new<size_t>(M);
	size_t* MathQ = FFLAS::fflas_new<size_t>(N);

	LAPACKPerm2MathPerm (MathP, P, M);
	LAPACKPerm2MathPerm (MathQ, Q, N);
	for (size_t i = 0; i < R; i++)
		if (MathP[i] < LSm && MathQ[i] < LSn){
			RRP [LSr] = MathP[i];
			CRP [LSr] = MathQ[i];
			LSr++;
		}
	std::sort (RRP, RRP+LSr);
	std::sort (CRP, CRP+LSr);
	FFLAS::fflas_delete(MathP);
	FFLAS::fflas_delete(MathQ);
	return LSr;
			
}


template <class Field>
size_t RowRankProfileSubmatrixIndices (const Field& F,
									   const size_t M, const size_t N,
									   typename Field::Element_ptr A,
									   const size_t lda,
									   size_t*& rowindices,
									   size_t*& colindices,
									   size_t& R)
{
	size_t *P = FFLAS::fflas_new<size_t>(N);
	size_t *Q = FFLAS::fflas_new<size_t>(M);
	
	R = LUdivine (F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, M, N, A, lda, P, Q);
	rowindices = FFLAS::fflas_new<size_t>(M);
	colindices = FFLAS::fflas_new<size_t>(N);
	for (size_t i=0; i<R; ++i){
		rowindices [i] = Q [i];
	}
	for (size_t i=0; i<N; ++i)
		colindices [i] = i;
	size_t tmp;
	for (size_t i=0; i<R; ++i){
		if (i != P[i]){
			tmp = colindices[i];
			colindices[i] = colindices[P[i]];
			colindices[P[i]] = tmp;
		}
	}
	
	FFLAS::fflas_delete( P);
	FFLAS::fflas_delete( Q);
	
	return R;
}
	
template <class Field>
size_t ColRankProfileSubmatrixIndices (const Field& F,
									   const size_t M, const size_t N,
									   typename Field::Element_ptr A,
									   const size_t lda,
									   size_t*& rowindices,
									   size_t*& colindices,
									   size_t& R)
{
	size_t *P = FFLAS::fflas_new<size_t>(M);
	size_t *Q = FFLAS::fflas_new<size_t>(N);
	
	R = LUdivine (F, FFLAS::FflasNonUnit, FFLAS::FflasTrans, M, N, A, lda, P, Q);
	rowindices = FFLAS::fflas_new<size_t>(M);
	colindices = FFLAS::fflas_new<size_t>(N);
	for (size_t i=0; i<R; ++i)
		colindices [i] = Q [i];
	
	for (size_t i=0; i<N; ++i)
		rowindices [i] = i;
	
	size_t tmp;
	for (size_t i=0; i<R; ++i){
		if (i != P[i]){
			tmp = rowindices[i];
			rowindices[i] = rowindices[P[i]];
			rowindices[P[i]] = tmp;
		}
	}
	FFLAS::fflas_delete( P);
	FFLAS::fflas_delete( Q);
	
	return R;
}
	
template <class Field>
size_t RowRankProfileSubmatrix (const Field& F,
								const size_t M, const size_t N,
								typename Field::Element_ptr A,
								const size_t lda,
								typename Field::Element_ptr& X, size_t& R)
{
	
	size_t * rowindices, * colindices;
	
	typename Field::Element_ptr A2 = FFLAS::fflas_new (F, M, N) ;
	FFLAS::fassign(F,M,N,A,lda,A2,N);

	RowRankProfileSubmatrixIndices (F, M, N, A2, N, rowindices, colindices, R);

	X = FFLAS::fflas_new (F, R, R);
	for (size_t i=0; i<R; ++i)
		for (size_t j=0; j<R; ++j)
			F.assign (*(X + i*R + j), *(A + rowindices[i]*lda + colindices[j]));
	FFLAS::fflas_delete (A2);
	FFLAS::fflas_delete( rowindices);
	FFLAS::fflas_delete( colindices);
	return R;
}

template <class Field>
size_t ColRankProfileSubmatrix (const Field& F, const size_t M, const size_t N,
								typename Field::Element_ptr A, const size_t lda,
								typename Field::Element_ptr& X, size_t& R)
{
	
	size_t * rowindices, * colindices;

	typename Field::Element_ptr A2 = FFLAS::fflas_new (F, M, N);
	FFLAS::fassign(F,M,N,A,lda,A2,N);

	ColRankProfileSubmatrixIndices (F, M, N, A2, N, rowindices, colindices, R);

	X = FFLAS::fflas_new (F, R, R);
	for (size_t i=0; i<R; ++i)
		for (size_t j=0; j<R; ++j)
			F.assign (*(X + i*R + j), *(A + rowindices[i]*lda + colindices[j]));
	FFLAS::fflas_delete (A2);
	FFLAS::fflas_delete( colindices);
	FFLAS::fflas_delete( rowindices);
	return R;
}
	
template <class Field>
typename Field::Element_ptr
LQUPtoInverseOfFullRankMinor( const Field& F, const size_t rank,
							  typename Field::Element_ptr A_factors, const size_t lda,
							  const size_t* QtPointer,
							  typename Field::Element_ptr X, const size_t ldx)
{

		// upper entries are okay, just need to move up bottom ones
	const size_t* srcRow = QtPointer;
	for (size_t row=0; row<rank; row++, srcRow++)
		if (*srcRow != row) {
			typename Field::Element_ptr oldRow = A_factors + (*srcRow) * lda;
			typename Field::Element_ptr newRow = A_factors + row * lda;
			for (size_t col=0; col<row; col++, oldRow++, newRow++)
				F.assign(*newRow, *oldRow);
		}
	
		// X <- (Qt.L.Q)^(-1)
		//invL( F, rank, A_factors, lda, X, ldx);
	ftrtri (F, FFLAS::FflasLower, FFLAS::FflasUnit, rank, A_factors, lda);
	FFLAS::fassign(F,rank,rank,X,ldx,A_factors,lda);
	
		// X = U^-1.X
	ftrsm( F, FFLAS::FflasLeft, FFLAS::FflasUpper, FFLAS::FflasNoTrans,
		   FFLAS::FflasNonUnit, rank, rank, F.one, A_factors, lda, X, ldx);
	
	return X;
	
}

} // namespace FFPACK

#endif // __FFLASFFPACK_ffpack_rank_profiles_INL