Go to the documentation of this file.00001 #ifndef VectorDoublet_H
00002 #define VectorDoublet_H
00003
00004 #include "DataFormats/GeometryVector/interface/PreciseFloatType.h"
00005
00006 template <class V1, class V2>
00007 class VectorDoublet {
00008 public:
00009
00010 typedef typename V1::ScalarType Scalar1;
00011 typedef typename V2::ScalarType Scalar2;
00012
00013 VectorDoublet() {}
00014 VectorDoublet( const V1& a, const V2& b) : a_(a), b_(b) {}
00015
00016 const V1& first() const {return a_;}
00017 const V2& second() const {return b_;}
00018
00019 VectorDoublet& operator+= ( const VectorDoublet& v) {
00020 a_ += v.first();
00021 b_ += v.second();
00022 return *this;
00023 }
00024 VectorDoublet& operator-= ( const VectorDoublet& v) {
00025 a_ -= v.first();
00026 b_ -= v.second();
00027 return *this;
00028 }
00029
00030 VectorDoublet operator-() const { return VectorDoublet( -a_, -b_);}
00031
00032 template <class T>
00033 VectorDoublet& operator*= ( const T& t) {
00034 a_ *= t;
00035 b_ *= t;
00036 return *this;
00037 }
00038 template <class T>
00039 VectorDoublet& operator/= ( const T& t) {
00040 a_ /= t;
00041 b_ /= t;
00042 return *this;
00043 }
00044
00045 typename PreciseFloatType<Scalar1,Scalar2>::Type dot( const VectorDoublet& v) const {
00046 return first()*v.first() + second()*v.second();
00047 }
00048
00049 private:
00050
00051 V1 a_;
00052 V2 b_;
00053
00054 };
00055
00057 template <class V1, class V2>
00058 inline VectorDoublet<V1,V2>
00059 operator+( const VectorDoublet<V1,V2>& a, const VectorDoublet<V1,V2>& b) {
00060 return VectorDoublet<V1,V2>(a.first()+b.first(), a.second()+b.second());
00061 }
00062
00063 template <class V1, class V2>
00064 inline VectorDoublet<V1,V2>
00065 operator-( const VectorDoublet<V1,V2>& a, const VectorDoublet<V1,V2>& b) {
00066 return VectorDoublet<V1,V2>(a.first()-b.first(), a.second()-b.second());
00067 }
00068
00072 template <class V1, class V2, class Scalar>
00073 inline VectorDoublet<V1,V2> operator*( const VectorDoublet<V1,V2>& v, const Scalar& s) {
00074 return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
00075 }
00076 template <class V1, class V2, class Scalar>
00077 inline VectorDoublet<V1,V2> operator*( const Scalar& s, const VectorDoublet<V1,V2>& v) {
00078 return VectorDoublet<V1,V2>( v.first()*s, v.second()*s);
00079 }
00080
00081 template <class V1, class V2, class Scalar>
00082 inline VectorDoublet<V1,V2> operator/( const VectorDoublet<V1,V2>& v, const Scalar& s) {
00083 return VectorDoublet<V1,V2>( v.first()/s, v.second()/s);
00084 }
00085
00086 #endif