This file is indexed.

/usr/include/fplll/nr/numvect.h is in libfplll-dev 5.2.0-3build1.

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
/* Copyright (C) 2011 Xavier Pujol.

   This file is part of fplll. fplll 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.

   fplll 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 fplll. If not, see <http://www.gnu.org/licenses/>. */

#ifndef FPLLL_NUMVECT_H
#define FPLLL_NUMVECT_H

#include "fplll/nr/nr.h"
#include <vector>

FPLLL_BEGIN_NAMESPACE

/** Extends the size of the given vector. */
template <class T> void extend_vect(vector<T> &v, int size)
{
  if (static_cast<int>(v.size()) < size)
  {
    v.resize(size);
  }
}

/** Reverses a vector by consecutive swaps. */
template <class T> void reverse_by_swap(vector<T> &v, int first, int last)
{
  for (; first < last; first++, last--)
    v[first].swap(v[last]);
}

/** Rotates a vector by consecutive swaps. */
template <class T> void rotate_by_swap(vector<T> &v, int first, int middle, int last)
{
  // Algorithm from STL code
  reverse_by_swap(v, first, middle - 1);
  reverse_by_swap(v, middle, last);
  for (; first < middle && middle <= last; first++, last--)
  {
    v[first].swap(v[last]);
  }
  if (first == middle)
    reverse_by_swap(v, middle, last);
  else
    reverse_by_swap(v, first, middle - 1);
}

/** Rotates a vector left-wise by consecutive swaps. */
template <class T> void rotate_left_by_swap(vector<T> &v, int first, int last)
{
  FPLLL_DEBUG_CHECK(0 <= first && first <= last && last < static_cast<int>(v.size()));
  for (int i = first; i < last; i++)
  {
    v[i].swap(v[i + 1]);
  }
}

/** Rotates a vector right-wise by consecutive swaps. */
template <class T> void rotate_right_by_swap(vector<T> &v, int first, int last)
{
  FPLLL_DEBUG_CHECK(0 <= first && first <= last && last < static_cast<int>(v.size()));
  for (int i = last - 1; i >= first; i--)
  {
    v[i].swap(v[i + 1]);
  }
}

/** Print a vector on stream os. */
template <class T> ostream &operator<<(ostream &os, const vector<T> &v)
{
  os << "[";
  int n = v.size();
  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      os << " ";
    os << v[i];
  }
  os << "]";
  return os;
}

/** Reads a vector from stream is. */
template <class T> istream &operator>>(istream &is, vector<T> &v)
{
  char c;
  v.clear();
  if (!(is >> c))
    return is;
  if (c != '[')
  {
    is.setstate(ios::failbit);
    return is;
  }
  while (is >> c && c != ']')
  {
    is.putback(c);
    v.resize(v.size() + 1);
    if (!(is >> v.back()))
    {
      v.pop_back();
      return is;
    }
  }
  return is;
}

/** Generate a zero vector. */
template <class T> void gen_zero_vect(vector<T> &v, int n)
{
  v.resize(n);
  fill(v.begin(), v.end(), 0);
}

template <class T> class NumVect;

template <class T> ostream &operator<<(ostream &os, const NumVect<T> &v);

template <class T> istream &operator>>(istream &is, NumVect<T> &v);

template <class T> class NumVect
{
public:
  typedef typename vector<T>::iterator iterator;
  /** Creates an empty NumVect (0). */
  NumVect() {}
  /** Initializes NumVect with the elements of the given NumVect. */
  NumVect(const NumVect &v) : data(v.data) {}
  /** Initializes NumVect of specific size, The initial content is
      undefined. */
  NumVect(int size) : data(size) {}
  NumVect(int size, const T &t) : data(size, t) {}
  /** Sets the NumVect to the elements of the given NumVect. */
  void operator=(const NumVect &v)
  {
    if (this != &v)
      data = v.data;
  }
  /** Swaps the data between the NumVect and the given NumVect. */
  void swap(NumVect &v) { data.swap(v.data); }
  /** Returns an iterator to the beginning of NumVect.*/
  const iterator begin() { return data.begin(); }
  /** Returns an iterator to the end of NumVect. */
  iterator end() { return data.end(); }
  /** Returns the number of elements in NumVect. */
  int size() const { return data.size(); }
  /** Checks whether NumVect is empty. */
  bool empty() const { return data.empty(); }
  /** Sets the size of NumVect. */
  void resize(int size) { data.resize(size); }
  /** Sets the size of NumVect and all its elemnts to t.*/
  void resize(int size, const T &t) { data.resize(size, t); }
  /** Sets the size of NumVect and all its elements to zero. */
  void gen_zero(int size)
  {
    data.resize(size);
    fill(0);
  }
  /** Inserts an element in the back of NumVect. */
  void push_back(const T &t) { data.push_back(t); }
  /** Removes the back element of NumVect. */
  void pop_back() { data.pop_back(); }
  /** Returns a reference to the front element of NumVect. */
  T &front() { return data.front(); }
  /** Returns a const reference to the front element of NumVect,
      on constant object. */
  const T &front() const { return data.front(); }
  /** Returns a reference to the back element of NumVect. */
  T &back() { return data.back(); }
  /** Returns a const reference to the back element of NumVect,
      on constant object. */
  const T &back() const { return data.back(); }
  /** Extends the size of NumVect, only if it is needed. */
  void extend(int maxSize)
  {
    if (size() < maxSize)
      data.resize(maxSize);
  }
  void clear() { data.clear(); }
  /** Returns a reference to the i-th element of NumVect. */
  T &operator[](int i) { return data[i]; }
  /** Returns a const reference to the i-th element of NumVect on constant
      object. */
  const T &operator[](int i) const { return data[i]; }
  /** Addition of two NumVector objects, till index n. */
  void add(const NumVect<T> &v, int n);
  /** Addition of two NumVector objects. */
  void add(const NumVect<T> &v) { add(v, size()); }
  /** Subtraction of two NumVector objects, till index n. */
  void sub(const NumVect<T> &v, int n);
  /** Subtraction of two NumVector objects. */
  void sub(const NumVect<T> &v) { sub(v, size()); }
  /** Multiplication of NumVector and a number c, till index n. */
  void mul(const NumVect<T> &v, int n, T c);
  /** Multiplication of NumVector and a number c. */
  void mul(const NumVect<T> &v, T c) { mul(v, size(), c); }
  /** Incremeanting each coefficient of NumVector by its product with
      number c, till index n. */
  void addmul(const NumVect<T> &v, T x, int n);
  /** Incremeanting each coefficient of NumVector by its product with
      number c. */
  void addmul(const NumVect<T> &v, T x) { addmul(v, x, size()); }
  void addmul_2exp(const NumVect<T> &v, const T &x, long expo, T &tmp)
  {
    addmul_2exp(v, x, expo, size(), tmp);
  }
  void addmul_2exp(const NumVect<T> &v, const T &x, long expo, int n, T &tmp);
  void addmul_si(const NumVect<T> &v, long x) { addmul_si(v, x, size()); }
  void addmul_si(const NumVect<T> &v, long x, int n);
  void addmul_si_2exp(const NumVect<T> &v, long x, long expo, T &tmp)
  {
    addmul_si_2exp(v, x, expo, size(), tmp);
  }
  void addmul_si_2exp(const NumVect<T> &v, long x, long expo, int n, T &tmp);

  /** (v[first],...,v[last]) becomes (v[first+1],...,v[last],v[first]) */
  void rotate_left(int first, int last) { rotate_left_by_swap(data, first, last); }

  /** (v[first],...,v[last]) becomes (v[last],v[first],...,v[last-1]) */
  void rotate_right(int first, int last) { rotate_right_by_swap(data, first, last); }

  /** Returns expo >= 0 such that all elements are < 2^expo. */
  long get_max_exponent();

  /** Fills NumVect with the value given. */
  void fill(long value);

  /** Checks if NumVect has zero elements from fromCol. */
  bool is_zero(int fromCol = 0) const;

  /** Returns last non-zero index of NumVector. */
  int size_nz() const;

  friend ostream &operator<<<T>(ostream &os, const NumVect<T> &v);
  friend istream &operator>><T>(istream &is, NumVect<T> &v);

private:
  vector<T> data;
};

template <class T> void NumVect<T>::add(const NumVect<T> &v, int n)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
    data[i].add(data[i], v[i]);
}

template <class T> void NumVect<T>::sub(const NumVect<T> &v, int n)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
    data[i].sub(data[i], v[i]);
}

template <class T> void NumVect<T>::mul(const NumVect<T> &v, int n, T c)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
    data[i].mul(v[i], c);
}

template <class T> void NumVect<T>::addmul(const NumVect<T> &v, T x, int n)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
    data[i].addmul(v[i], x);
}

template <class T>
void NumVect<T>::addmul_2exp(const NumVect<T> &v, const T &x, long expo, int n, T &tmp)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
  {
    tmp.mul(v[i], x);
    tmp.mul_2si(tmp, expo);
    data[i].add(data[i], tmp);
  }
}

template <class T> void NumVect<T>::addmul_si(const NumVect<T> &v, long x, int n)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
    data[i].addmul_si(v[i], x);
}

template <class T>
void NumVect<T>::addmul_si_2exp(const NumVect<T> &v, long x, long expo, int n, T &tmp)
{
  FPLLL_DEBUG_CHECK(n <= size() && size() == v.size() && v.is_zero(n));
  for (int i = n - 1; i >= 0; i--)
  {
    tmp.mul_si(v[i], x);
    tmp.mul_2si(tmp, expo);
    data[i].add(data[i], tmp);
  }
}

template <class T> long NumVect<T>::get_max_exponent()
{
  long max_expo = 0;
  for (int i = 0; i < size(); i++)
  {
    max_expo = max(max_expo, data[i].exponent());
  }
  return max_expo;
}

template <class T> void NumVect<T>::fill(long value)
{
  for (int i = 0; i < size(); i++)
  {
    data[i] = value;
  }
}

template <class T> bool NumVect<T>::is_zero(int fromCol) const
{
  for (int i = fromCol; i < size(); i++)
  {
    if (!data[i].is_zero())
      return false;
  }
  return true;
}

template <class T> int NumVect<T>::size_nz() const
{
  int i;
  for (i = data.size(); i > 0; i--)
  {
    if (data[i - 1] != 0)
      break;
  }
  return i;
}

template <class T> void dot_product(T &result, const NumVect<T> &v1, const NumVect<T> &v2, int n)
{
  FPLLL_DEBUG_CHECK(n > 0 && n <= v1.size() && v1.size() == v2.size() &&
                    (v1.is_zero(n) || v2.is_zero(n)));
  result.mul(v1[0], v2[0]);
  for (int i = 1; i < n; i++)
  {
    result.addmul(v1[i], v2[i]);
  }
}

template <class T> inline void dot_product(T &result, const NumVect<T> &v1, const NumVect<T> &v2)
{
  dot_product(result, v1, v2, v1.size());
}

template <class T> inline void squared_norm(T &result, const NumVect<T> &v)
{
  dot_product(result, v, v);
}

/** Prints a NumVect on stream os. */
template <class T> ostream &operator<<(ostream &os, const NumVect<T> &v) { return os << v.data; }

/** Reads a NumVect from stream is. */
template <class T> istream &operator>>(istream &is, NumVect<T> &v) { return is >> v.data; }

FPLLL_END_NAMESPACE

#endif