JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
TNumericUtil.hh
Go to the documentation of this file.
1 #ifndef NUMERIC_UTILITIES
2 #define NUMERIC_UTILITIES
3 
4 #include <vector>
5 
6 
7 namespace TNumericUtil{
8 
9  template<typename T> struct triplet{
10  T value[3];
11  triplet(T i1, T i2, T i3){
12  value[0]=i1;
13  value[1]=i2;
14  value[2]=i3;
15  }
16  triplet(T i1){
17  value[0]=i1;
18  value[1]=i1;
19  value[2]=i1;
20  }
21  triplet(){}
22  T& operator[](std::size_t ipos){ return value[ipos]; } // Return by reference
23  const T& operator[](std::size_t ipos)const{ return value[ipos]; } // Return by const reference
24  bool operator == (const triplet<T>& other)const{ bool res = true; for (std::size_t i=0; i<3; i++) res &= (*this)[i]==other[i]; return res; }
25  bool operator != (const triplet<T>& other)const{ return !(*this==other); }
26  };
27  template<typename T> struct quadruplet{
28  T value[4];
29  quadruplet(T i1, T i2, T i3, T i4){
30  value[0]=i1;
31  value[1]=i2;
32  value[2]=i3;
33  value[3]=i4;
34  }
35  quadruplet(T i1){ for (unsigned int idim=0; idim<4; idim++) value[idim] = i1; }
37  T& operator[](std::size_t ipos){ return value[ipos]; } // Return by reference
38  const T& operator[](std::size_t ipos)const{ return value[ipos]; } // Return by const reference
39  bool operator == (const quadruplet<T>& other)const{ bool res = true; for (std::size_t i=0; i<4; i++) res &= (*this)[i]==other[i]; return res; }
40  bool operator != (const quadruplet<T>& other)const{ return !(*this==other); }
41  };
42 
47 
52 
53  void PermutationGenerator(int n, int k, std::vector<std::vector<int>>& perms, int valbegin=1, int increment=1); // n!/(n-k)! different permutations of {i_1,...,i_k}, i+j in {valbegin,...,valbegin+increment*(n-1)}
54  void CombinationGenerator(int n, int k, std::vector<std::vector<int>>& perms, int valbegin=1, int increment=1); // n!/(k!(n-k)!) different combinations (unordered permutations) of {i_1,...,i_k}, i+j in {valbegin,...,valbegin+increment*(n-1)}
55 
56 }
57 
58 #endif
59 
TNumericUtil::triplet::triplet
triplet(T i1, T i2, T i3)
Definition: TNumericUtil.hh:11
TNumericUtil::floatQuad_t
quadruplet< float > floatQuad_t
Definition: TNumericUtil.hh:50
TNumericUtil::intQuad_t
quadruplet< int > intQuad_t
Definition: TNumericUtil.hh:49
TNumericUtil::doubleTriplet_t
triplet< double > doubleTriplet_t
Definition: TNumericUtil.hh:46
TNumericUtil::triplet::triplet
triplet(T i1)
Definition: TNumericUtil.hh:16
TNumericUtil::quadruplet::operator[]
const T & operator[](std::size_t ipos) const
Definition: TNumericUtil.hh:38
TNumericUtil::triplet::operator!=
bool operator!=(const triplet< T > &other) const
Definition: TNumericUtil.hh:25
TNumericUtil::floatTriplet_t
triplet< float > floatTriplet_t
Definition: TNumericUtil.hh:45
TNumericUtil::quadruplet::quadruplet
quadruplet(T i1, T i2, T i3, T i4)
Definition: TNumericUtil.hh:29
TNumericUtil::triplet::value
T value[3]
Definition: TNumericUtil.hh:10
TNumericUtil::quadruplet::quadruplet
quadruplet()
Definition: TNumericUtil.hh:36
TNumericUtil::quadruplet::operator==
bool operator==(const quadruplet< T > &other) const
Definition: TNumericUtil.hh:39
TNumericUtil::quadruplet::operator!=
bool operator!=(const quadruplet< T > &other) const
Definition: TNumericUtil.hh:40
TNumericUtil::uintTriplet_t
triplet< unsigned int > uintTriplet_t
Definition: TNumericUtil.hh:43
TNumericUtil
Definition: MELAAccumulators.h:6
TNumericUtil::PermutationGenerator
void PermutationGenerator(int n, int k, std::vector< std::vector< int >> &perms, int valbegin=1, int increment=1)
Definition: TNumericUtil.cc:7
TNumericUtil::triplet::operator[]
T & operator[](std::size_t ipos)
Definition: TNumericUtil.hh:22
TNumericUtil::quadruplet::quadruplet
quadruplet(T i1)
Definition: TNumericUtil.hh:35
TNumericUtil::triplet
Definition: TNumericUtil.hh:9
TNumericUtil::intTriplet_t
triplet< int > intTriplet_t
Definition: TNumericUtil.hh:44
TNumericUtil::CombinationGenerator
void CombinationGenerator(int n, int k, std::vector< std::vector< int >> &perms, int valbegin=1, int increment=1)
Definition: TNumericUtil.cc:19
TNumericUtil::quadruplet::operator[]
T & operator[](std::size_t ipos)
Definition: TNumericUtil.hh:37
TNumericUtil::uintQuad_t
quadruplet< unsigned int > uintQuad_t
Definition: TNumericUtil.hh:48
TNumericUtil::quadruplet
Definition: TNumericUtil.hh:27
TNumericUtil::quadruplet::value
T value[4]
Definition: TNumericUtil.hh:28
TNumericUtil::doubleQuad_t
quadruplet< double > doubleQuad_t
Definition: TNumericUtil.hh:51
TNumericUtil::triplet::triplet
triplet()
Definition: TNumericUtil.hh:21
TNumericUtil::triplet::operator==
bool operator==(const triplet< T > &other) const
Definition: TNumericUtil.hh:24
TNumericUtil::triplet::operator[]
const T & operator[](std::size_t ipos) const
Definition: TNumericUtil.hh:23