This file is indexed.

/usr/include/Rivet/Math/VectorN.hh is in librivet-dev 1.8.3-1.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
#ifndef RIVET_MATH_VECTORN
#define RIVET_MATH_VECTORN

#include "Rivet/Math/MathHeader.hh"
#include "Rivet/Math/MathUtils.hh"

#include "Rivet/Math/eigen/vector.h"

namespace Rivet {


  template <size_t N>
  class Vector;
  template <size_t N>
  class Matrix;

  template <size_t N>
  Vector<N> multiply(const Matrix<N>& a, const Vector<N>& b);


  /// A minimal base class for \f$ N \f$-dimensional vectors.
  template <size_t N>
  class Vector {
    template <size_t M>
    friend Vector<M> multiply(const Matrix<M>& a, const Vector<M>& b);

  public:
    Vector() { _vec.loadZero(); }

    Vector(const Vector<N>& other)
      : _vec(other._vec) { }

    const double& get(const size_t index) const {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }

    /// Direct access to vector elements by index.
    const double& operator[](const size_t index) const {
      return get(index);
    }

    /// Direct access to vector elements by index.
    double& operator[](const size_t index) {
      return get(index);
    }

    /// Set indexed value
    Vector<N>& set(const size_t index, const double value) {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        _vec[index] = value;
      }
      return *this;
    }

    /// Vector dimensionality
    size_t size() const {
      return N;
    }

    /// Check for nullness, allowing for numerical precision
    bool isZero(double tolerance=1E-5) const {
      for (size_t i=0; i < N; ++i) {
        if (! Rivet::isZero(_vec[i], tolerance) ) return false;
      }
      return true;
    }

    /// @brief Calculate the modulus-squared of a vector.
    /// \f$ \sum_{i=1}^N x_i^2 \f$.
    double mod2() const {
      double mod2 = 0.0;
      for (size_t i = 0; i < size(); ++i) {
        const double element = get(i);
        mod2 += element*element;
      }
      return mod2;
    }

    /// @brief Calculate the modulus of a vector.
    /// \f$ \sqrt{\sum_{i=1}^N x_i^2} \f$.
    double mod() const {
      const double norm = mod2();
      assert(norm >= 0);
      return sqrt(norm);
    }

    /// Invert the vector
    Vector<N> operator-() const {
      Vector<N> rtn;
      rtn._vec = -_vec;
      return rtn;
    }

    bool operator==(const Vector<N>& a) const {
      return _vec == a._vec;
    }

    bool operator!=(const Vector<N>& a) const {
      return _vec != a._vec;
    }

    bool operator<(const Vector<N>& a) const {
      return _vec < a._vec;
    }

    bool operator<=(const Vector<N>& a) const {
      return _vec <= a._vec;
    }

    bool operator>(const Vector<N>& a) const {
      return _vec > a._vec;
    }

    bool operator>=(const Vector<N>& a) const {
      return _vec >= a._vec;
    }


  protected:
    double& get(const size_t index) {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }

    /// Vector
    Eigen::Vector<double,N> _vec;
  };



  /// Calculate the modulus-squared of a vector.
  /// \f$ \sum_{i=1}^N x_i^2 \f$.
  template <size_t N>
  inline double mod2(const Vector<N>& v) {
    return v.mod2();
  }

  /// Calculate the modulus of a vector.
  /// \f$ \sqrt{\sum_{i=1}^N x_i^2} \f$.
  template <size_t N>
  inline double mod(const Vector<N>& v) {
    return v.mod();
  }


  /////////////////////////////////////////////////


  /// @name String representations of vectors
  //@{

  /// Make string representation
  template <size_t N>
  inline const string toString(const Vector<N>& v) {
    ostringstream out;
    out << "(";
    for (size_t i = 0; i < v.size(); ++i) {
      out << (fabs(v[i]) < 1E-30 ? 0.0 : v[i]);
      if (i < v.size()-1) out << ", ";
    }
    out << ")";
    return out.str();
  }

  /// Stream out string representation
  template <size_t N>
  inline std::ostream& operator<<(std::ostream& out, const Vector<N>& v) {
    out << toString(v);
    return out;
  }

  //@}


  /////////////////////////////////////////////////


  /// Compare two vectors by index, allowing for numerical precision
  template <size_t N>
  inline bool fuzzyEquals(const Vector<N>& va, const Vector<N>& vb, double tolerance=1E-5) {
    for (size_t i = 0; i < N; ++i) {
      const double a = va.get(i);
      const double b = vb.get(i);
      if (!Rivet::fuzzyEquals(a, b, tolerance)) return false;
    }
    return true;
  }


  /// External form of numerically safe nullness check
  template <size_t N>
  inline bool isZero(const Vector<N>& v, double tolerance=1E-5) {
    return v.isZero(tolerance);
  }


}

#endif