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 
11  typedef typename V1::ScalarType Scalar1;
12  typedef typename V2::ScalarType Scalar2;
13 
15  VectorDoublet( const V1& a, const V2& b) : a_(a), b_(b) {}
16 
17  const V1& first() const {return a_;}
18  const V2& second() const {return b_;}
19 
21  a_ += v.first();
22  b_ += v.second();
23  return *this;
24  }
26  a_ -= v.first();
27  b_ -= v.second();
28  return *this;
29  }
30 
31  VectorDoublet operator-() const { return VectorDoublet( -a_, -b_);}
32 
33  template <class T>
35  a_ *= t;
36  b_ *= t;
37  return *this;
38  }
39  template <class T>
41  a_ /= t;
42  b_ /= t;
43  return *this;
44  }
45 
47  return first()*v.first() + second()*v.second();
48  }
49 
50 private:
51 
52  V1 a_;
53  V2 b_;
54 
55 };
56 
58 template <class V1, class V2>
61  return VectorDoublet<V1,V2>(a.first()+b.first(), a.second()+b.second());
62 }
63 
64 template <class V1, class V2>
67  return VectorDoublet<V1,V2>(a.first()-b.first(), a.second()-b.second());
68 }
69 
73 template <class V1, class V2, class Scalar>
75  return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
76 }
77 template <class V1, class V2, class Scalar>
79  return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
80 }
81 
82 template <class V1, class V2, class Scalar>
84  return VectorDoublet<V1,V2>( v.first()/s, v.second()/s);
85 }
86 
87 #endif
Basic3DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
VectorDoublet(const V1 &a, const V2 &b)
Definition: VectorDoublet.h:15
double Scalar
Definition: Definitions.h:27
Basic3DVector & operator-=(const Basic3DVector< U > &p)
T ScalarType
const V1 & first() const
Definition: VectorDoublet.h:17
U second(std::pair< T, U > const &p)
V1::ScalarType Scalar1
Definition: VectorDoublet.h:11
#define dso_internal
Definition: Visibility.h:13
V2::ScalarType Scalar2
Definition: VectorDoublet.h:12
VectorDoublet< V1, V2 > operator-(const VectorDoublet< V1, V2 > &a, const VectorDoublet< V1, V2 > &b)
Definition: VectorDoublet.h:66
PreciseFloatType< Scalar1, Scalar2 >::Type dot(const VectorDoublet &v) const
Definition: VectorDoublet.h:46
const V2 & second() const
Definition: VectorDoublet.h:18
Basic3DVector & operator/=(T t)
Scaling by a scalar value (division)
VectorDoublet< V1, V2 > operator+(const VectorDoublet< V1, V2 > &a, const VectorDoublet< V1, V2 > &b)
vector sum and subtraction
Definition: VectorDoublet.h:60
double b
Definition: hdecay.h:120
VectorDoublet< V1, V2 > operator/(const VectorDoublet< V1, V2 > &v, const Scalar &s)
Definition: VectorDoublet.h:83
double a
Definition: hdecay.h:121
VectorDoublet operator-() const
Definition: VectorDoublet.h:31
VectorDoublet< V1, V2 > operator*(const VectorDoublet< V1, V2 > &v, const Scalar &s)
Definition: VectorDoublet.h:74
long double T
Basic3DVector & operator+=(const Basic3DVector< U > &p)