This file is indexed.

/usr/include/ASL/math/aslVectorsDynamicLengthOperations.h is in libasl-dev 0.1.7-2.

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
/*
 * Advanced Simulation Library <http://asl.org.il>
 * 
 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
 *
 *
 * This file is part of Advanced Simulation Library (ASL).
 *
 * ASL is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, version 3 of the License.
 *
 * ASL 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
 *
 */


/// \file aslVectors.h definition of class АVec<T>

#ifndef ASLVECTORSDYNAMICLENGTHOPERATIONS_H
#define ASLVECTORSDYNAMICLENGTHOPERATIONS_H


#include "../aslUtilities.h"
#include <cmath>


namespace asl
{
	
	/// The function checks whether the sizes are equal \relates AVec
	template <typename T1, typename T2> 
		inline bool compatibleSizes(AVec<T1> a, AVec<T2> b);

	/// \relates AVec	
	template <typename T> 
		inline const T l2(const AVec<T> & a);

	/// \relates AVec	
	template <typename T> 
		inline const AVec<> normalize(const AVec<T> & a);
	
	/// \relates AVec	
	template <typename T> 
		inline const AVec<T> operator+(const AVec<T> & a, const AVec<T> & b);
	/// \relates AVec
	template <typename T> 
		inline const AVec<T> operator-(const AVec<T> & a, const AVec<T> & b);
	/// \relates AVec
	template <typename T> 
		inline const AVec<T> operator-(const AVec<T> & a);
	/// \relates AVec
	template <typename T> 
		inline const T operator*(const AVec<T> & a, const AVec<T> & b);	
	/// \relates AVec
	template <typename T> 
		inline const AVec<T> operator*(const T & a, const AVec<T> & b);	
	/// \relates AVec
	template <typename T> 
		inline const AVec<T> operator*(const AVec<T> & a, const T & b);		
	/// \relates AVec
	template <typename T> 
		inline const AVec<T> operator/(const AVec<T> & a, const T & b);		

	/// \relates AVec
	template <typename T> inline const AVec<T> & operator+=(AVec<T> & a,
	                                                        const AVec<T> & b);
	/// \relates AVec
	template <typename T> inline const AVec<T> & operator-=(AVec<T> & a,
	                                                        const AVec<T> & b);
	/// \relates AVec
	template <typename T> inline const AVec<T> & operator*=(AVec<T> & a,
	                                                        const T & b);		

	/// \relates AVec
	template <typename T> inline const bool operator==(const AVec<T> & a,
	                                                   const AVec<T> & b);
	

	/// \relates AVec
	template <typename T> inline const bool operator!=(const AVec<T> & a,
	                                                   const AVec<T> & b);
	

	/// \relates AVec
	template <typename T> 
		inline const AVec<T> crossProduct(const AVec<T> & a, const AVec<T> & b);	

	/// returns minimal component \relates AVec 
	template <typename T> inline const T minComponent(const AVec<T> & a);		
	/// returns maximal component  \relates AVec
	template <typename T> inline const T maxComponent(const AVec<T> & a);		

	/// returns summ of all components \relates AVec
	template <typename T> inline T sumOfElements(const AVec<T> & a);
	/// returns product of all components \relates AVec
	template <typename T> inline T productOfElements(const AVec<T> & a);

	/// returns vector which elements are product of corresponding elements of \p a and \p b \relates AVec
	template <typename T> inline const AVec<T> productOfElements(const AVec<T> & a,
	                                                             const AVec<T> & b);
	/// returns vector which elements are division of corresponding elements of \p a and \p b \relates AVec
	template <typename T> inline const AVec<T> divisionOfElements(const AVec<T> & a,
	                                                              const AVec<T> & b);

	/// returns \p true in case when all components of \p a more or  then 0 \relates AVec 
	template <typename T> inline const bool positive(const AVec<T> & a);

	/// returns \p true in case when all components of \p a more or equal 0 \relates AVec 
	template <typename T> inline const bool nonNegative(const AVec<T> & a);
	
	/// returns \p true in case when all components of \p a more then 0 \relates AVec 
	inline const AVec<int> floor(const AVec<> & a);

	/// returns \p true in case when all components of \p a more then 0 \relates AVec 
	inline const AVec<int> round(const AVec<> & a);
	
	/// computes polynom for \p x with \p coefs 
	/**
		 \relates AVec
		 The polinom is \f$ x^{n-1}*coefs_0+x^{n-2}coefs_1+...+coefs_{n-1} \f$
	*/
	inline double computePolynom(double x, AVec<> &coefs);
	
	/// \relates AVec
	template <typename T> 
		inline std::ostream & operator<<(std::ostream & output, const AVec<T> & a);

	/// returns \p true in case when all components of \p a more then 0 \relates AVec 
	inline const AVec<> swapXZ(const AVec<> & a);
	
//---------------- Implementation ----------------

	template <typename T1, typename T2> 
	inline bool compatibleSizes(AVec<T1> a, AVec<T2> b)
	{
		return a.getSize() == b.getSize();
	}


	template <typename T> inline const T l2(const AVec<T> & a)
	{
		return a * a;
	}

	template <typename T> inline const AVec<> normalize(const AVec<T> & a)
	{
		return AVec<>(a) / sqrt(l2(a));
	}
	
	template <typename T> inline const AVec<T> operator+(const AVec<T> & a,
	                                                     const AVec<T> & b){
		if (!compatibleSizes(a, b))
			errorMessage("(AVec; operator+) Vector sizes are incompatible");
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c[i] = a[i] + b[i];
		return c;
	}

	template <typename T> inline const AVec<T> operator-(const AVec<T> & a, const AVec<T> & b)
	{
		if (!compatibleSizes (a,b))
			errorMessage("(AVec; operator-) Vector sizes are incompatible");
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c[i] =a[i]-b[i];
		return c;
	}

	template <typename T> inline const AVec<T> operator-(const AVec<T> & a)
	{
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c[i] =-a[i];
		return c;
	}
	
	template <typename T> inline const T operator*(const AVec<T> & a, const AVec<T> & b){
		if (!compatibleSizes (a,b))
			errorMessage("(AVec; operator*) Vector sizes are incompatible");
		T s(0);
		for (unsigned int i(0); i < a.getSize(); ++i) 
			s+=a[i]*b[i];
		return s;
	}

	template <typename T> inline const AVec<T> operator*(const AVec<T> & a, const T & b){
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c[i] =a[i]*b;
		return c;
	}

	template <typename T> inline const AVec<T> operator*(const T & a, const AVec<T> & b){
		return b*a;
	}

	template <typename T> inline const AVec<T> operator/(const AVec<T> & a, const T & b){
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c[i] =a[i]/b;
		return c;
	}
		
	template <typename T> inline const AVec<T> & operator+=(AVec<T> & a, const AVec<T> & b){
		if (!compatibleSizes (a,b))
			errorMessage("Vector sizes are incompatible");
		for (unsigned int i(0); i < a.getSize(); ++i) 
			a[i]+=b[i];
		return a;
	}

	template <typename T> inline const AVec<T> & operator-=(AVec<T> & a, const AVec<T> & b){
		if (!compatibleSizes (a,b))
			errorMessage("Vector sizes are incompatible");
		for (unsigned int i(0); i < a.size; ++i) 
			a[i]-=b[i];
		return a;
	}

	template <typename T> inline const AVec<T> & operator*=(AVec<T> & a, const T & b){
		for (unsigned int i(0); i < a.getSize(); ++i) 
			a[i] *= b;
		return a;
	}	

	template <typename T> inline const bool operator==(const AVec<T> & a,
	                                                   const AVec<T> & b)
	{
		if (!compatibleSizes (a, b))
			return false;
		bool c(true);
		for (unsigned int i(0); i < a.getSize(); ++i) 
			c = c && (a[i] == b[i]);
		return c;
	}


	template <typename T> inline const bool operator!=(const AVec<T> & a,
	                                                   const AVec<T> & b)
	{
		return !(a == b);
	}

	template <typename T> 
		inline const AVec<T> crossProduct(const AVec<T> & a, const AVec<T> & b)
	{
		if (!compatibleSizes (a,b))
			errorMessage("(AVec; crossProduct) Vector sizes are incompatible");
		if (a.getSize()>3)
			errorMessage("(AVec; crossProduct) number of components is more than 3");
		if (a.getSize()<2)
			errorMessage("(AVec; crossProduct) number of components is less than 2");

		AVec<T> res(1);
		if(a.getSize() == 2)
		{
			res[0] = a[0]*b[1]-a[1]*b[0];
		}
		if(a.getSize() == 3)
		{
			res.resize(3);
			res[0] = a[1]*b[2]-a[2]*b[1];
			res[1] = a[2]*b[0]-a[0]*b[2];
			res[2] = a[0]*b[1]-a[1]*b[0];
		}
		return res;
	}
	
	template <typename T> inline const T minComponent(const AVec<T> & a)
	{
		T ma(a[0]);
		for (unsigned int i(1); i < a.getSize(); ++i) 
			ma = std::min(ma, a[i]);
		return ma;
	}
		
	template <typename T> inline const T maxComponent(const AVec<T> & a)
	{
		if (a.getSize()<1) errorMessage("Vector size less than 1");
		T ma(a[0]);
		for (unsigned int i(1); i < a.getSize(); ++i) 
			ma=std::max(ma,a[i]);
		return ma;
	}

	template <typename T> inline AVec<T> subAVec(const AVec<T> & source,
	                       unsigned int start, unsigned int end)
	{
		if (source.getSize() <= end )
			errorMessage("subAVec: attempt to copy besides the vector range");
		
		AVec<T> destination(1 + end - start);
		for (unsigned int i(start); i <= end; ++i)
			destination[i - start] = source[i];
		return destination;
	}
	
	template <typename T> inline T sumOfElements(const AVec<T> & a)
	{
		T s(0);
		for (unsigned int i(0); i < a.getSize(); ++i)
			s += a[i];
		return s;
	}
		
	template <typename T> inline T productOfElements(const AVec<T> & a)
	{
		T p(1);
		for (unsigned int i(0); i < a.getSize(); ++i)
			p *= a[i];
		return p;
	}

	template <typename T> inline const AVec<T> productOfElements(const AVec<T> & a,
	                                                             const AVec<T> & b)
	{
		if (!compatibleSizes (a, b))
			errorMessage("(AVec; productOfElements) Vector sizes are incompatible");
		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i)
			c[i] = a[i] * b[i];
		return c;
	}

	template <typename T> inline const AVec<T> divisionOfElements(const AVec<T> & a, const AVec<T> & b)
	{
		if (!compatibleSizes (a, b))
			errorMessage("(AVec; divisionOfElements) Vector sizes are incompatible");

		AVec<T> c(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i)
			c[i] = a[i] / b[i];

		return c;
	}

	template <typename T> inline const bool positive(const AVec<T> & a)
	{
		if (!a.getSize())
			errorMessage("(AVec; positive) Vector size is zero");
		bool res(a[0]>0);
		for (unsigned int i(1); i < a.getSize(); ++i)
			res &= a[i]>0;
		return res;	
	}

	template <typename T> inline const bool nonNegative(const AVec<T> & a)
	{
		if (!a.getSize())
			errorMessage("(AVec; positive) Vector size is zero");
		bool res(a[0]>=0);
		for (unsigned int i(1); i < a.getSize(); ++i)
			res &= a[i]>=0;
		return res;	
	}
	
	inline const AVec<int> floor(const AVec<> & a)
	{
		if (!a.getSize())
			errorMessage("(AVec; floor) Vector size is zero");
		AVec<int> res(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i)
			res[i] = std::floor(a[i]);
		return res;	
	}

	inline const AVec<int> round(const AVec<> & a)
	{
		if (!a.getSize())
			errorMessage("(AVec; round) Vector size is zero");
		AVec<int> res(a.getSize());
		for (unsigned int i(0); i < a.getSize(); ++i)
			res[i] = std::round(a[i]);
		return res;	
	}

	
	inline double computePolynom (double x, AVec<> &coefs)
	{	
		if (coefs.getSize() < 1)
			errorMessage("Error: (asl::computePolynom) size of \"coefs\" less than 1");
		double p;
		p=coefs[0];
		for (unsigned int i(1); i < coefs.getSize(); ++i)
			p=p*x+coefs[i];
		return p;	
	}

	/// returns \p true in case when all components of \p a more then 0 \relates AVec 
	inline const AVec<> swapXZ(const AVec<> & a)
	{
		if (a.getSize()<3)
			errorMessage("(AVec; swapXZ) Vector size less than 3");
		AVec<> res(a);
		std::swap(res[0],res[2]);
		return res;		
	}
	
} // asl

#endif //ASLVECTORSDYNAMICLENGTH_H