thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
ACDC
ACDCTraits.h
1
// -*- C++ -*-
2
//
3
// ACDCTraits.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef ACDCTraits_H
10
#define ACDCTraits_H
11
12
namespace
ACDCGenerator
{
13
18
struct
ACDCTraitsType
{};
19
27
template
<
typename
FncPtr>
28
struct
ACDCFncTraits
:
public
ACDCTraitsType
{
29
34
static
inline
double
value
(
const
FncPtr & f,
const
DVector
& x) {
35
return
(*f)(x);
36
}
37
38
};
39
46
template
<
typename
Rnd>
47
struct
ACDCRandomTraits
:
public
ACDCTraitsType
{
48
52
static
inline
double
rnd
(Rnd * r) {
return
r->flat(); }
53
57
static
inline
double
rnd
(Rnd * r,
double
xl,
double
xu) {
58
return
xl + (xu - xl)*
rnd
(r);
59
}
60
72
template
<
typename
InputIterator,
typename
OutputIterator>
73
static
inline
void
rnd
(Rnd * r, InputIterator l, InputIterator lend,
74
InputIterator u, OutputIterator res) {
75
for
( ; l != lend; ++l ) *res++ = *l + (*u++ - *l)*
rnd
(r);
76
}
77
82
template
<
typename
OutputIterator>
83
static
inline
void
rnd
(Rnd * r,
int
D, OutputIterator res) {
84
for
(
int
d = 0; d < D; ++d ) *res++ =
rnd
(r);
85
}
86
90
static
inline
bool
rndBool
(Rnd * r,
double
x) {
return
rnd
(r) < x; }
91
95
static
inline
bool
rndBool
(Rnd * r,
double
x,
double
y) {
96
return
rndBool
(r, x/(x + y)); }
97
101
static
inline
long
rndInt
(Rnd * r,
long
x) {
102
return
long(
rnd
(r, 0.0,
double
(x)));
103
}
104
105
};
106
107
}
108
109
#endif
ACDCGenerator
The namespace in which all ACDCGen classes are defined.
Definition:
ACDCGen.h:18
ACDCGenerator::DVector
vector< double > DVector
A vector of doubles.
Definition:
ACDCGenConfig.h:58
ACDCGenerator::ACDCFncTraits
ACDCFncTraits defines the interface to functions to be sampled by ACDCGen.
Definition:
ACDCTraits.h:28
ACDCGenerator::ACDCFncTraits::value
static double value(const FncPtr &f, const DVector &x)
Call a function to be sampled by ACDCGen.
Definition:
ACDCTraits.h:34
ACDCGenerator::ACDCRandomTraits
ACDCRandomTraits defines the interface to random number generator objects to be used by ACDCGen.
Definition:
ACDCTraits.h:47
ACDCGenerator::ACDCRandomTraits::rndInt
static long rndInt(Rnd *r, long x)
Return a random integer in the interval [0,x[.
Definition:
ACDCTraits.h:101
ACDCGenerator::ACDCRandomTraits::rnd
static double rnd(Rnd *r)
Return a flat random number in the interval ]0,1[.
Definition:
ACDCTraits.h:52
ACDCGenerator::ACDCRandomTraits::rnd
static void rnd(Rnd *r, InputIterator l, InputIterator lend, InputIterator u, OutputIterator res)
Generate a set of random numbers.
Definition:
ACDCTraits.h:73
ACDCGenerator::ACDCRandomTraits::rndBool
static bool rndBool(Rnd *r, double x, double y)
Return true with probability x(x + y).
Definition:
ACDCTraits.h:95
ACDCGenerator::ACDCRandomTraits::rnd
static double rnd(Rnd *r, double xl, double xu)
Return a flat random number in the interval ]xl,xu[.
Definition:
ACDCTraits.h:57
ACDCGenerator::ACDCRandomTraits::rndBool
static bool rndBool(Rnd *r, double x)
Return true with probability x.
Definition:
ACDCTraits.h:90
ACDCGenerator::ACDCRandomTraits::rnd
static void rnd(Rnd *r, int D, OutputIterator res)
Generate D random numbers.
Definition:
ACDCTraits.h:83
ACDCGenerator::ACDCTraitsType
ACDCTraitsType is an empty non-polymorphic base class for all traits classes in ACDCGenerator.
Definition:
ACDCTraits.h:18
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6