JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
TNumericUtil Namespace Reference

Classes

class  KahanAccumulator
 
class  NaiveAccumulator
 
struct  quadruplet
 
struct  triplet
 

Typedefs

template<typename T >
using PreciseAccumulator = KahanAccumulator< T >
 
template<typename T >
using FastAccumulator = NaiveAccumulator< T >
 
template<typename T >
using DefaultAccumulator = PreciseAccumulator< T >
 
typedef triplet< unsigned int > uintTriplet_t
 
typedef triplet< int > intTriplet_t
 
typedef triplet< float > floatTriplet_t
 
typedef triplet< double > doubleTriplet_t
 
typedef quadruplet< unsigned int > uintQuad_t
 
typedef quadruplet< int > intQuad_t
 
typedef quadruplet< float > floatQuad_t
 
typedef quadruplet< double > doubleQuad_t
 

Functions

template<typename T , class A >
sumWith (const std::vector< T > &vals)
 
template<typename T >
sumPrecise (const std::vector< T, std::allocator< T >> &vals)
 
template<typename T >
sumFast (const std::vector< T, std::allocator< T >> &vals)
 
template<typename T >
sumDefault (const std::vector< T, std::allocator< T >> &vals)
 
void PermutationGenerator (int n, int k, std::vector< std::vector< int >> &perms, int valbegin=1, int increment=1)
 
void CombinationGenerator (int n, int k, std::vector< std::vector< int >> &perms, int valbegin=1, int increment=1)
 

Typedef Documentation

◆ DefaultAccumulator

template<typename T >
using TNumericUtil::DefaultAccumulator = typedef PreciseAccumulator<T>

Definition at line 55 of file MELAAccumulators.h.

◆ doubleQuad_t

Definition at line 51 of file TNumericUtil.hh.

◆ doubleTriplet_t

Definition at line 46 of file TNumericUtil.hh.

◆ FastAccumulator

template<typename T >
using TNumericUtil::FastAccumulator = typedef NaiveAccumulator<T>

Definition at line 54 of file MELAAccumulators.h.

◆ floatQuad_t

Definition at line 50 of file TNumericUtil.hh.

◆ floatTriplet_t

Definition at line 45 of file TNumericUtil.hh.

◆ intQuad_t

Definition at line 49 of file TNumericUtil.hh.

◆ intTriplet_t

Definition at line 44 of file TNumericUtil.hh.

◆ PreciseAccumulator

template<typename T >
using TNumericUtil::PreciseAccumulator = typedef KahanAccumulator<T>

Definition at line 53 of file MELAAccumulators.h.

◆ uintQuad_t

typedef quadruplet<unsigned int> TNumericUtil::uintQuad_t

Definition at line 48 of file TNumericUtil.hh.

◆ uintTriplet_t

typedef triplet<unsigned int> TNumericUtil::uintTriplet_t

Definition at line 43 of file TNumericUtil.hh.

Function Documentation

◆ CombinationGenerator()

void TNumericUtil::CombinationGenerator ( int  n,
int  k,
std::vector< std::vector< int >> &  perms,
int  valbegin = 1,
int  increment = 1 
)

Definition at line 19 of file TNumericUtil.cc.

19  {
20  if (n==k && k>0){
21  vector<int> d(n);
22  iota(d.begin(), d.end(), 1);
23  perms.push_back(d);
24  }
25  else{
26  PermutationGenerator(n, k, perms);
27  for (auto& perm:perms) sort(perm.begin(), perm.end());
28  for (auto ip=perms.begin(); ip!=perms.end(); ip++){
29  for (auto jp=perms.rbegin(); (jp.base()-1)!=ip; jp++){
30  if (*(ip)==*(jp)) perms.erase(jp.base()-1);
31  }
32  }
33  }
34  if (valbegin!=1 || increment!=1){ for (auto& p:perms){ for (auto& pp:p) pp = increment*(pp-1)+valbegin; } }
35 }

◆ PermutationGenerator()

void TNumericUtil::PermutationGenerator ( int  n,
int  k,
std::vector< std::vector< int >> &  perms,
int  valbegin = 1,
int  increment = 1 
)

Definition at line 7 of file TNumericUtil.cc.

7  {
8  if (n<=0 || k<=0 || k>n) return;
9  vector<int> d(n);
10  iota(d.begin(), d.end(), 1);
11  do{
12  vector<int> aperm;
13  for (int i=0; i<k; i++) aperm.push_back(d[i]);
14  perms.push_back(aperm);
15  reverse(d.begin()+k, d.end());
16  } while (next_permutation(d.begin(), d.end()));
17  if (valbegin!=1 || increment!=1){ for (auto& p:perms){ for (auto& pp:p) pp = increment*(pp-1)+valbegin; } }
18 }

◆ sumDefault()

template<typename T >
T TNumericUtil::sumDefault ( const std::vector< T, std::allocator< T >> &  vals)
inline

Definition at line 73 of file MELAAccumulators.h.

73  {
74  T ret = sumWith<T, DefaultAccumulator<T>>(vals);
75  return ret;
76  }

◆ sumFast()

template<typename T >
T TNumericUtil::sumFast ( const std::vector< T, std::allocator< T >> &  vals)
inline

Definition at line 68 of file MELAAccumulators.h.

68  {
69  T ret = sumWith<T, FastAccumulator<T>>(vals);
70  return ret;
71  }

◆ sumPrecise()

template<typename T >
T TNumericUtil::sumPrecise ( const std::vector< T, std::allocator< T >> &  vals)
inline

Definition at line 63 of file MELAAccumulators.h.

63  {
64  T ret = sumWith<T, PreciseAccumulator<T>>(vals);
65  return ret;
66  }

◆ sumWith()

template<typename T , class A >
T TNumericUtil::sumWith ( const std::vector< T > &  vals)
inline

Definition at line 57 of file MELAAccumulators.h.

57  {
58  A ret = 0;
59  for (const T& v : vals) ret += v;
60  return ret;
61  }
TNumericUtil::PermutationGenerator
void PermutationGenerator(int n, int k, std::vector< std::vector< int >> &perms, int valbegin=1, int increment=1)
Definition: TNumericUtil.cc:7