This file is indexed.

/usr/include/ThePEG/Config/PhysicalQty.h is in libthepeg-dev 1.8.0-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
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
// -*- C++ -*-
//
// PhysicalQty.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 2006-2011 David Grellscheid, Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef Physical_Qty_H
#define Physical_Qty_H
#include "TemplateTools.h"
#include <sstream>

/** @file 
 *
 * The PhysicalQty class allows compile-time checking of dimensional
 * correctness. Mathematical operations that are inconsistent are
 * flagged as type errors.
 *
 * Do not use the classes directly in ThePEG, use the wrappers defined
 * in Units.h or Phys_Qty.h instead.
 */

namespace ThePEG {

/// Helper class to construct zero unitful quantities.
struct ZeroUnit {
  /** Automatic conversion to double. */
  operator double() const { return 0.0; }
};

/// ZERO can be used as zero for any unitful quantity.
const ZeroUnit ZERO = ZeroUnit();

/// Helper classes to extend or shorten fractions
//@{
/**
 * Template to help with fractional powers of dimensions 
 */
template <int M, int II>
struct QtyHelper 
{
  /// The numerator, indicating failure.
  static const int I = -999999;
};

/**
 * Template to help with fractional powers of dimensions
 */
template <int II>
struct QtyHelper<0,II> 
{
  /// The new numerator.
  static const int I = II;
};

/**
 * Template to help with fractional powers of dimensions 
 */
template <int II, int DI, int DI2>
struct QtyInt 
{
  /// The new numerator.
  static const int I = QtyHelper<(DI2*II)%DI,(DI2*II)/DI>::I;
};
//@}

/**
 * This template class allows the compiler to check calculations with
 * physical quantities for dimensional correctness. A quantity can be
 * composed of arbitrary fractional powers of length L, energy E and
 * charge Q. Commonly used quantities should be typedef'ed (see Units.h).
 *
 * Some member functions can break dimensional consistency if the user
 * is not careful; these are marked explicitly.
 *
 * Do not use this class directly in ThePEG, use the pre-defined quantities
 * from Units.h or the wrapper in Phys_Qty.h instead.
 */
template<int L, int E, int Q, int DL = 1, int DE = 1, int DQ = 1>
class Qty
{
private:
  /// Constructor from raw values. Breaks consistency.
  Qty(double val) : rawValue_(val) {}

public:

  /// The name of the class for persistent IO
  static std::string className() {
    std::ostringstream os;
    os << "Qty<" 
       <<  L << ','
       <<  E << ','
       <<  Q << ','
       << DL << ','
       << DE << ','
       << DQ << '>';
      
    return os.str();
  }


  /// The squared type.
  typedef Qty<2*L,2*E,2*Q,DL,DE,DQ> Squared;

  /// Basic unit of this quantity.
  static Qty<L,E,Q,DL,DE,DQ> baseunit() 
  {
    return Qty<L,E,Q,DL,DE,DQ>(1.0);
  }

  /// Default constructor to 0.
  Qty() : rawValue_(0.0) {}

  /// Default constructor to 0.
  Qty(ZeroUnit) : rawValue_(0.0) {}

  /// Constructor from a compatible quantity
  template <int DL2, int DE2, int DQ2>
  Qty(const Qty<QtyInt<L,DL,DL2>::I,
                QtyInt<E,DE,DE2>::I,
                QtyInt<Q,DQ,DQ2>::I,
                DL2,DE2,DQ2> & q)
    : rawValue_(q.rawValue()) {}

  /// Access to the raw value. Breaks consistency.
  double rawValue() const { return rawValue_; }

  /// Assignment multiplication by dimensionless number.
  Qty<L,E,Q,DL,DE,DQ> & operator*=(double x) { rawValue_ *= x; return *this; }

  /// Assignment division by dimensionless number.
  Qty<L,E,Q,DL,DE,DQ> & operator/=(double x) { rawValue_ /= x; return *this; }

  /// Assignment addition with compatible quantity.
  template <int DL2, int DE2, int DQ2>
  Qty<L,E,Q,DL,DE,DQ> & 
  operator+=(const Qty<QtyInt<L,DL,DL2>::I,
	               QtyInt<E,DE,DE2>::I,
	               QtyInt<Q,DQ,DQ2>::I,
	               DL2,DE2,DQ2> x) 
  { 
    rawValue_ += x.rawValue(); 
    return *this; 
  }

  /// Assignment subtraction with compatible quantity.
  template <int DL2, int DE2, int DQ2>
  Qty<L,E,Q,DL,DE,DQ> & 
  operator-=(const Qty<QtyInt<L,DL,DL2>::I,
	               QtyInt<E,DE,DE2>::I,
	               QtyInt<Q,DQ,DQ2>::I,
  	               DL2,DE2,DQ2> x) 
  { 
    rawValue_ -= x.rawValue(); 
    return *this; 
  }

private:
  /// The raw value in units of Qty::baseunit().
  double rawValue_;
};

/// Specialization of Qty for <0,0,0> with conversions to double.
template<int DL, int DE, int DQ>
class Qty<0,0,0,DL,DE,DQ>
{
public:
  /// The squared type.
  typedef Qty<0,0,0,DL,DE,DQ> Squared;

  /// Basic unit of this quantity.
  static double baseunit() {
    return 1.0;
  }

  /// Default constructor to 0.
  Qty(ZeroUnit) : rawValue_(0.0) {}

  /// Default constructor from a double.
  Qty(double x = 0.0) : rawValue_(x) {}

  /// Constructor from a compatible quantity
  template <int DL2, int DE2, int DQ2>
  Qty(const Qty<0,0,0,DL2,DE2,DQ2> & q) : rawValue_(q.rawValue()) {}

  /// Access to the raw value.
  double rawValue() const { return rawValue_; }

  /// Cast to double.
  operator double() const { return rawValue_; }

  /// Assignment multiplication by dimensionless number.
  Qty<0,0,0,DL,DE,DQ> & operator*=(double x) { rawValue_ *= x; return *this; }

  /// Assignment division by dimensionless number.
  Qty<0,0,0,DL,DE,DQ> & operator/=(double x) { rawValue_ /= x; return *this; }

  /// Assignment addition with compatible quantity.
  template <int DL2, int DE2, int DQ2>
  Qty<0,0,0,DL,DE,DQ> & operator+=(const Qty<0,0,0,DL2,DE2,DQ2> x) { 
    rawValue_ += x.rawValue(); 
    return *this; 
  }

  /// Assignment subtraction with compatible quantity.
  template <int DL2, int DE2, int DQ2>
  Qty<0,0,0,DL,DE,DQ> & operator-=(const Qty<0,0,0,DL2,DE2,DQ2> x) { 
    rawValue_ -= x.rawValue(); 
    return *this; 
  }

  /// Assignment addition with double.
  Qty<0,0,0,DL,DE,DQ> & operator+=(double x) { 
    rawValue_ += x; 
    return *this; 
  }

  /// Assignment subtraction with double.
  Qty<0,0,0,DL,DE,DQ> & operator-=(double x) { 
    rawValue_ -= x; 
    return *this; 
  }

private:
  /// The raw value.
  double rawValue_;
};

/// @name Result types for binary operations.
//@{
/**
 * BinaryOpTraits should be specialized with typdefs called MulT and
 * DivT which gives the type resulting when multiplying and dividing
 * the template argument types respectively.
 */
template <typename T, typename U> 
struct BinaryOpTraits;

/** @cond TRAITSPECIALIZATIONS */

template<int L1, int L2, int E1, int E2, int Q1, int Q2,
	 int DL1, int DL2, int DE1, int DE2, int DQ1, int DQ2>
struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
		      Qty<L2,E2,Q2,DL2,DE2,DQ2> > {
  /** The type resulting from multiplication of the template type with
      itself. */
  typedef Qty<L1*DL2+L2*DL1,E1*DE2+E2*DE1,Q1*DQ2+Q2*DQ1,
              DL1*DL2,DE1*DE2,DQ1*DQ2> MulT;
  /** The type resulting from division of one template type with
      another. */
  typedef Qty<L1*DL2-L2*DL1,E1*DE2-E2*DE1,Q1*DQ2-Q2*DQ1,
              DL1*DL2,DE1*DE2,DQ1*DQ2> DivT;
};


template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
		      Qty<L1,E1,Q1,DL1,DE1,DQ1> > {
  /** The type resulting from multiplication of the template type with
      itself. */
  typedef Qty<2*L1,2*E1,2*Q1,
              DL1,DE1,DQ1> MulT;
  /** The type resulting from division of one template type with
      another. */
  typedef double DivT;
};

/**
 *  Multiplication template
 */
template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
struct BinaryOpTraits<double,
		      Qty<L1,E1,Q1,DL1,DE1,DQ1> > {
  /** The type resulting from multiplication of the template type with
      itself. */
  typedef Qty<L1,E1,Q1,
              DL1,DE1,DQ1> MulT;
  /** The type resulting from division of one template type with
      another. */
  typedef Qty<-L1,-E1,-Q1,
              DL1,DE1,DQ1> DivT;
};

/**
 *  Multiplication template
 */
template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
		      double> {
  /** The type resulting from multiplication of the template type with
      itself. */
  typedef Qty<L1,E1,Q1,
              DL1,DE1,DQ1> MulT;
  /** The type resulting from division of one template type with
      another. */
  typedef Qty<L1,E1,Q1,
              DL1,DE1,DQ1> DivT;
};
//@}

/// @name Type traits for alternative code generation.
//@{
/** Type traits for alternative code generation*/
template <int L, int E, int Q, int DL, int DE, int DQ> 
struct TypeTraits<Qty<L,E,Q,DL,DE,DQ> >
{
  /** Enum for dimensions*/
  enum { hasDimension = true };
  /// Type switch set to dimensioned type.
  typedef DimensionT DimType;
  static const Qty<L,E,Q,DL,DE,DQ> baseunit;
};

/** Type traits for alternative code generation*/
template <int L, int E, int Q, int DL, int DE, int DQ> 
const Qty<L,E,Q,DL,DE,DQ> 
TypeTraits<Qty<L,E,Q,DL,DE,DQ> >::baseunit = Qty<L,E,Q,DL,DE,DQ>::baseunit();


/** Type traits for alternative code generation*/
template <int DL, int DE, int DQ> 
struct TypeTraits<Qty<0,0,0,DL,DE,DQ> >
{
  /** Enum for dimensions*/
  enum { hasDimension = false };
  /// Type switch set to standard type.
  typedef StandardT DimType;
  static const double baseunit;
};

/** Type traits for alternative code generation*/
template <int DL, int DE, int DQ> 
const double 
TypeTraits<Qty<0,0,0,DL,DE,DQ> >::baseunit = 1.0;
//@}

/** @endcond */

}

#endif