This file is indexed.

/usr/include/fplll/util.h is in libfplll-dev 4.0.4-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
/* Copyright (C) 2005-2008 Damien Stehle.
   Copyright (C) 2007 David Cade.
   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/>. */
/** \file util.h
    Miscellaneous. */

#ifndef FPLLL_UTIL_H
#define FPLLL_UTIL_H

#include "matrix.h"

FPLLL_BEGIN_NAMESPACE

static inline int cputime() {
#ifdef FPLLL_WITH_GETRUSAGE
  struct rusage rus;
  getrusage(RUSAGE_SELF, &rus);
  return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
#else
  return time(NULL) * 1000;
#endif
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template<class ZT>
void vectMatrixProduct(vector<ZT>& result, const vector<ZT>& x, const Matrix<ZT>& m) {
  int nRows = m.getRows(), nCols = m.getCols();
  genZeroVect(result, nCols);
  for (int i = 0; i < nRows; i++)
    for (int j = 0; j < nCols; j++)
      result[j].addmul(x[i], m(i, j));
}

/* Computes result = x * m (it is not required that result is initialized,
   x.size() must be equal to m.GetNumRows()) */
template<class ZT>
void vectMatrixProduct(NumVect<ZT>& result, const NumVect<ZT>& x, const Matrix<ZT>& m) {
  int nRows = m.getRows(), nCols = m.getCols();
  result.gen_zero(nCols);
  for (int i = 0; i < nRows; i++)
    for (int j = 0; j < nCols; j++)
      result[j].addmul(x[i], m(i, j));
}

template<class T>
void scalarProduct(T& result, const MatrixRow<T>& v1, const MatrixRow<T>& v2, int n) {
  FPLLL_DEBUG_CHECK(n <= static_cast<int>(v1.size())
          && n <= static_cast<int>(v2.size()));
  T tmp;
  result.mul(v1[0], v2[0]);
  for (int i = 1; i < n; i++) {
    tmp.mul(v1[i], v2[i]);
    result.add(result, tmp);
  }
}

template<class T>
inline void sqrNorm(T& result, const MatrixRow<T>& v, int n) {
  scalarProduct(result, v, v, n);
}

/** Prints x on stream os. */
template<class T>
ostream& operator<<(ostream& os, const Z_NR<T>& x) {
  return os << x.getData();
}

template<>
ostream& operator<<(ostream& os, const Z_NR<mpz_t>& x);

/** Prints x on stream os. */
template<class T>
ostream& operator<<(ostream& os, const FP_NR<T>& x) {
  return os << x.getData();
}

#ifdef FPLLL_WITH_DPE
template<>
ostream& operator<<(ostream& os, const FP_NR<dpe_t>& x);
#endif

template<>
ostream& operator<<(ostream& os, const FP_NR<mpfr_t>& x);

/** Reads x from stream is. */
template<class T>
istream& operator>>(istream& is, Z_NR<T>& x) {
  return is >> x.getData();
}

template<>
istream& operator>>(istream& is, Z_NR<mpz_t>& x);

const double DEF_GSO_PREC_EPSILON = 0.03;

/**
 * Returns the minimum precision required to ensure that error bounds on the
 * GSO are valid. Computes rho such that for all 0 &lt;= i &lt; d and 0 &lt;= j &lt;= i:
 *
 *   |r~_i - r_i| / r_i     <= d * rho ^ (i + 1) * 2 ^ (2 - prec)
 *
 *   |mu~_(i,j) - mu_(i,j)| <= d * rho ^ (i + 1) * 2 ^ (4 - prec)
 */
int gsoMinPrec(double& rho, int d, double delta, double eta,
               double epsilon = DEF_GSO_PREC_EPSILON);

/**
 * Returns the minimum precision for the proved version of LLL.
 */
int l2MinPrec(int d, double delta, double eta, double epsilon);

/**
 * Computes the volume of a d-dimensional hypersphere of radius 1.
 */
void sphereVolume(Float& volume, int d);

/**
 * Estimates the cost of the enumeration for SVP.
 */
void costEstimate(Float& cost, const Float& bound,
                  const Matrix<Float>& r, int dimMax);

#ifdef FPLLL_V3_COMPAT

void gramSchmidt(const IntMatrix& b, Matrix<Float>& mu, FloatVect& rdiag);

template<class ZT>
inline void ScalarProduct(Z_NR<ZT>& s, const Z_NR<ZT>* vec1,
  const Z_NR<ZT>* vec2, int n) {

  Z_NR<ZT> tmp;
  s.mul(vec1[0],vec2[0]);

  for (int i=1;i<n;i++)
    {
      tmp.mul(vec1[i],vec2[i]);
      s.add(s,tmp);
    }
}

inline double fpScalarProduct(double* vec1, double* vec2, int n) {
  int i;
  double sum;

  sum = vec1[0] * vec2[0];
  for (i=1; i<n; i++)
    sum += vec1[i] * vec2[i];

  return sum;
} 

template<class FT>
inline void fpScalarProduct(FP_NR<FT>& result, const FP_NR<FT>* v1,
                            const FP_NR<FT>* v2, int n) {
  result.mul(v1[0], v2[0]);
  for (int i = 1; i < n; i++)
    result.addmul(v1[i], v2[i]);
} 

inline double fpNorm(double* vec, int n) {
  int i;
  double sum;

  sum = vec[0] * vec[0];
  for (i = 1 ; i < n ; i++)
    sum += vec[i]*vec[i];

  return sum;
} 

template<class FT> inline void fpNorm (FP_NR<FT>& s, FP_NR<FT> *vec, int n)
{
  int i;
  FP_NR<FT> tmp;
  
  s.mul(vec[0], vec[0]);
  
  for (i=1; i<n; i++)
    {
      tmp.mul(vec[i], vec[i]);
      s.add(s, tmp);
    }
} 

// Provided for compatibility, do not use
class Lexer {
public:
  Lexer() : is(&cin), fromFile(false) {};
  Lexer(const char* fileName) {
    is = new ifstream(fileName);
  }
  ~Lexer() {
    if (fromFile) delete is;
  }
  template<class T>
  Lexer& operator>>(T& x) {
    *is >> x;
    return *this;
  }
private:
  istream* is;
  bool fromFile;
};

#endif

FPLLL_END_NAMESPACE

#endif