CMS 3D CMS Logo

VectorDoublet.h
Go to the documentation of this file.
1 #ifndef VectorDoublet_H
2 #define VectorDoublet_H
3 
6 
7 template <class V1, class V2>
9 public:
10  typedef typename V1::ScalarType Scalar1;
11  typedef typename V2::ScalarType Scalar2;
12 
14  VectorDoublet(const V1& a, const V2& b) : a_(a), b_(b) {}
15 
16  const V1& first() const { return a_; }
17  const V2& second() const { return b_; }
18 
20  a_ += v.first();
21  b_ += v.second();
22  return *this;
23  }
25  a_ -= v.first();
26  b_ -= v.second();
27  return *this;
28  }
29 
30  VectorDoublet operator-() const { return VectorDoublet(-a_, -b_); }
31 
32  template <class T>
34  a_ *= t;
35  b_ *= t;
36  return *this;
37  }
38  template <class T>
40  a_ /= t;
41  b_ /= t;
42  return *this;
43  }
44 
46  return first() * v.first() + second() * v.second();
47  }
48 
49 private:
50  V1 a_;
51  V2 b_;
52 };
53 
55 template <class V1, class V2>
57  return VectorDoublet<V1, V2>(a.first() + b.first(), a.second() + b.second());
58 }
59 
60 template <class V1, class V2>
62  return VectorDoublet<V1, V2>(a.first() - b.first(), a.second() - b.second());
63 }
64 
68 template <class V1, class V2, class Scalar>
70  return VectorDoublet<V1, V2>(v.first() * s, v.second() * s);
71 }
72 template <class V1, class V2, class Scalar>
74  return VectorDoublet<V1, V2>(v.first() * s, v.second() * s);
75 }
76 
77 template <class V1, class V2, class Scalar>
79  return VectorDoublet<V1, V2>(v.first() / s, v.second() / s);
80 }
81 
82 #endif
VectorDoublet & operator/=(const T &t)
Definition: VectorDoublet.h:39
VectorDoublet & operator*=(const T &t)
Definition: VectorDoublet.h:33
VectorDoublet(const V1 &a, const V2 &b)
Definition: VectorDoublet.h:14
double Scalar
Definition: Definitions.h:25
VectorDoublet< V1, V2 > operator+(const VectorDoublet< V1, V2 > &a, const VectorDoublet< V1, V2 > &b)
vector sum and subtraction
Definition: VectorDoublet.h:56
T ScalarType
VectorDoublet< V1, V2 > operator-(const VectorDoublet< V1, V2 > &a, const VectorDoublet< V1, V2 > &b)
Definition: VectorDoublet.h:61
U second(std::pair< T, U > const &p)
const V2 & second() const
Definition: VectorDoublet.h:17
PreciseFloatType< Scalar1, Scalar2 >::Type dot(const VectorDoublet &v) const
Definition: VectorDoublet.h:45
VectorDoublet & operator-=(const VectorDoublet &v)
Definition: VectorDoublet.h:24
const V1 & first() const
Definition: VectorDoublet.h:16
V1::ScalarType Scalar1
Definition: VectorDoublet.h:10
VectorDoublet< V1, V2 > operator*(const VectorDoublet< V1, V2 > &v, const Scalar &s)
Definition: VectorDoublet.h:69
#define dso_internal
Definition: Visibility.h:13
VectorDoublet< V1, V2 > operator/(const VectorDoublet< V1, V2 > &v, const Scalar &s)
Definition: VectorDoublet.h:78
V2::ScalarType Scalar2
Definition: VectorDoublet.h:11
VectorDoublet & operator+=(const VectorDoublet &v)
Definition: VectorDoublet.h:19
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
VectorDoublet operator-() const
Definition: VectorDoublet.h:30
long double T