CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VectorDoublet.h
Go to the documentation of this file.
1 #ifndef VectorDoublet_H
2 #define VectorDoublet_H
3 
5 
6 template <class V1, class V2>
7 class VectorDoublet {
8 public:
9 
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>
33  VectorDoublet& operator*= ( const T& t) {
34  a_ *= t;
35  b_ *= t;
36  return *this;
37  }
38  template <class T>
39  VectorDoublet& operator/= ( const T& 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 
51  V1 a_;
52  V2 b_;
53 
54 };
55 
57 template <class V1, class V2>
60  return VectorDoublet<V1,V2>(a.first()+b.first(), a.second()+b.second());
61 }
62 
63 template <class V1, class V2>
66  return VectorDoublet<V1,V2>(a.first()-b.first(), a.second()-b.second());
67 }
68 
72 template <class V1, class V2, class Scalar>
74  return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
75 }
76 template <class V1, class V2, class Scalar>
78  return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
79 }
80 
81 template <class V1, class V2, class Scalar>
83  return VectorDoublet<V1,V2>( v.first()/s, v.second()/s);
84 }
85 
86 #endif
T ScalarType
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:27
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
const V1 & first() const
Definition: VectorDoublet.h:16
VectorDoublet & operator-=(const VectorDoublet &v)
Definition: VectorDoublet.h:24
V1::ScalarType Scalar1
Definition: VectorDoublet.h:10
Basic2DVector< T > operator/(const Basic2DVector< T > &v, const Scalar &s)
V2::ScalarType Scalar2
Definition: VectorDoublet.h:11
PreciseFloatType< Scalar1, Scalar2 >::Type dot(const VectorDoublet &v) const
Definition: VectorDoublet.h:45
const V2 & second() const
Definition: VectorDoublet.h:17
VectorDoublet & operator+=(const VectorDoublet &v)
Definition: VectorDoublet.h:19
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
VectorDoublet operator-() const
Definition: VectorDoublet.h:30
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
string s
Definition: asciidump.py:422
mathSSE::Vec4< T > v