10 #define Physical_Qty_H
29 operator double()
const {
return 0.0; }
40 template <
int M,
int II>
44 static const int I = -999999;
54 static const int I = II;
60 template <
int II,
int DI,
int DI2>
80 template<
int L,
int E,
int Q,
int DL = 1,
int DE = 1,
int DQ = 1>
91 std::ostringstream os;
105 typedef Qty<2*L,2*E,2*Q,DL,DE,DQ> Squared;
108 static Qty<L,E,Q,DL,DE,DQ> baseunit()
110 return Qty<L,E,Q,DL,DE,DQ>(1.0);
114 Qty() : rawValue_(0.0) {}
117 Qty(ZeroUnit) : rawValue_(0.0) {}
120 template <int DL2, int DE2, int DQ2>
121 Qty(const Qty<QtyInt<L,DL,DL2>::I,
125 : rawValue_(q.rawValue()) {}
128 double rawValue() const { return rawValue_; }
131 Qty<L,E,Q,DL,DE,DQ> & operator*=(double x) { rawValue_ *= x; return *this; }
134 Qty<L,E,Q,DL,DE,DQ> & operator/=(double x) { rawValue_ /= x; return *this; }
137 template <int DL2, int DE2, int DQ2>
138 Qty<L,E,Q,DL,DE,DQ> &
139 operator+=(const Qty<QtyInt<L,DL,DL2>::I,
144 rawValue_ += x.rawValue();
149 template <int DL2, int DE2, int DQ2>
150 Qty<L,E,Q,DL,DE,DQ> &
151 operator-=(const Qty<QtyInt<L,DL,DL2>::I,
156 rawValue_ -= x.rawValue();
166 template<int DL, int DE, int DQ>
167 class Qty<0,0,0,DL,DE,DQ>
171 typedef Qty<0,0,0,DL,DE,DQ> Squared;
174 static double baseunit() {
179 Qty(ZeroUnit) : rawValue_(0.0) {}
182 Qty(double x = 0.0) : rawValue_(x) {}
185 template <int DL2, int DE2, int DQ2>
186 Qty(const Qty<0,0,0,DL2,DE2,DQ2> & q) : rawValue_(q.rawValue()) {}
189 double rawValue() const { return rawValue_; }
192 operator double() const { return rawValue_; }
195 Qty<0,0,0,DL,DE,DQ> & operator*=(double x) { rawValue_ *= x; return *this; }
198 Qty<0,0,0,DL,DE,DQ> & operator/=(double x) { rawValue_ /= x; return *this; }
201 template <int DL2, int DE2, int DQ2>
202 Qty<0,0,0,DL,DE,DQ> & operator+=(const Qty<0,0,0,DL2,DE2,DQ2> x) {
203 rawValue_ += x.rawValue();
208 template <int DL2, int DE2, int DQ2>
209 Qty<0,0,0,DL,DE,DQ> & operator-=(const Qty<0,0,0,DL2,DE2,DQ2> x) {
210 rawValue_ -= x.rawValue();
215 Qty<0,0,0,DL,DE,DQ> & operator+=(double x) {
221 Qty<0,0,0,DL,DE,DQ> & operator-=(double x) {
238 template <typename T, typename U>
239 struct BinaryOpTraits;
243 template<int L1, int L2, int E1, int E2, int Q1, int Q2,
244 int DL1, int DL2, int DE1, int DE2, int DQ1, int DQ2>
245 struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
246 Qty<L2,E2,Q2,DL2,DE2,DQ2> > {
249 typedef Qty<L1*DL2+L2*DL1,E1*DE2+E2*DE1,Q1*DQ2+Q2*DQ1,
250 DL1*DL2,DE1*DE2,DQ1*DQ2> MulT;
253 typedef Qty<L1*DL2-L2*DL1,E1*DE2-E2*DE1,Q1*DQ2-Q2*DQ1,
254 DL1*DL2,DE1*DE2,DQ1*DQ2> DivT;
258 template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
259 struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
260 Qty<L1,E1,Q1,DL1,DE1,DQ1> > {
263 typedef Qty<2*L1,2*E1,2*Q1,
273 template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
274 struct BinaryOpTraits<double,
275 Qty<L1,E1,Q1,DL1,DE1,DQ1> > {
278 typedef Qty<L1,E1,Q1,
282 typedef Qty<-L1,-E1,-Q1,
289 template<int L1, int E1, int Q1, int DL1, int DE1, int DQ1>
290 struct BinaryOpTraits<Qty<L1,E1,Q1,DL1,DE1,DQ1>,
294 typedef Qty<L1,E1,Q1,
298 typedef Qty<L1,E1,Q1,
305 /** Type traits for alternative code generation*/
306 template <int L, int E, int Q, int DL, int DE, int DQ>
307 struct TypeTraits<Qty<L,E,Q,DL,DE,DQ> >
310 enum { hasDimension = true };
312 typedef DimensionT DimType;
313 static const Qty<L,E,Q,DL,DE,DQ> baseunit;
317 template <int L, int E, int Q, int DL, int DE, int DQ>
318 const Qty<L,E,Q,DL,DE,DQ>
319 TypeTraits<Qty<L,E,Q,DL,DE,DQ> >::baseunit = Qty<L,E,Q,DL,DE,DQ>::baseunit();
323 template <int DL, int DE, int DQ>
324 struct TypeTraits<Qty<0,0,0,DL,DE,DQ> >
327 enum { hasDimension = false };
329 typedef StandardT DimType;
330 static const double baseunit;
334 template <int DL, int DE, int DQ>
336 TypeTraits<Qty<0,0,0,DL,DE,DQ> >::baseunit = 1.0;
Helper class to construct zero unitful quantities.
Helper classes to extend or shorten fractions.
Qty(double val)
Constructor from raw values. Breaks consistency.
This is the main namespace within which all identifiers in ThePEG are declared.
double rawValue_
The raw value in units of Qty::baseunit().
static const int I
The new numerator.
static const int I
The numerator, indicating failure.
const ZeroUnit ZERO
ZERO can be used as zero for any unitful quantity.
Template to help with fractional powers of dimensions.
static std::string className()
The name of the class for persistent IO.
This template class allows the compiler to check calculations with physical quantities for dimensiona...