ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MixMaxEngine.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Tue Aug 4 2015
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2015 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // random engines based on ROOT
12 
13 #ifndef ROOT_Math_MixMaxEngine
14 #define ROOT_Math_MixMaxEngine
15 
16 #include <cstdint>
17 
18 #ifndef ROOT_Math_TRandomEngine
19 #include "Math/TRandomEngine.h"
20 #endif
21 
22 
23 struct rng_state_st; /// forward declare generator state
24 
25 typedef struct rng_state_st rng_state_t;
26 
27 
28 namespace ROOT {
29 
30  namespace Math {
31 
32 
33  /**
34  MIXMAX Random number generator.
35  It is a matrix-recursive random number generator introduced by
36  G. Savvidy in N.Z.Akopov, G.K.Savvidy and N.G.Ter-Arutyunian, _Matrix Generator of Pseudorandom Numbers_,
37  J.Comput.Phys. 97, 573 (1991) [DOI Link](http://dx.doi.org/10.1016/0021-9991(91)90016-E).
38  This is a new very fast impelmentation by K. Savvidy
39  by K. Savvidy and described in this paper,
40  K. Savvidy, _The MIXMAX Random Number Generator_, Comp. Phys. Communic. (2015)
41  [DOI link](http://dx.doi.org/10.1016/j.cpc.2015.06.003)
42 
43  The period of the generator is 10^4682 for N=256, and
44  10^1597 for N=88
45 
46  This implementation is only a wrapper around the real implemention, see mixmax.cxx and mixmax.h
47  The generator, in C code, is available also at hepforge: http://mixmax.hepforge.org
48 
49 
50  @ingroup Random
51  */
52 
53 
54  class MixMaxEngine : public TRandomEngine {
55 
56 
57  public:
58 
60 
61  MixMaxEngine(uint64_t seed=1);
62 
63  virtual ~MixMaxEngine();
64 
65  /// set the generator seed
66  void SetSeed(unsigned int seed);
67 
68  /// set the generator seed using a 64 bits integer
69  void SetSeed64(uint64_t seed);
70 
71  // generate a random number (virtual interface)
72  virtual double Rndm() { return Rndm_impl(); }
73 
74  /// generate a double random number (faster interface)
75  inline double operator() () { return Rndm_impl(); }
76 
77  /// generate an array of random numbers
78  void RndmArray (int n, double * array);
79 
80  /// generate a 64 bit integer number
81  uint64_t IntRndm();
82 
83  private:
84 
85  /// implementation function to generrate the random number
86  double Rndm_impl();
87 
88  rng_state_t * fRngState; // mix-max generator state
89 
90  };
91 
92 
93  } // end namespace Math
94 
95 } // end namespace ROOT
96 
97 
98 #endif /* ROOT_Math_TRandomEngines */
double operator()()
generate a double random number (faster interface)
Definition: MixMaxEngine.h:75
TRandomEngine BaseType
Definition: MixMaxEngine.h:59
virtual double Rndm()
Definition: MixMaxEngine.h:72
void SetSeed64(uint64_t seed)
set the generator seed using a 64 bits integer
void SetSeed(unsigned int seed)
set the generator seed
MIXMAX Random number generator.
Definition: MixMaxEngine.h:54
void RndmArray(int n, double *array)
generate an array of random numbers
uint64_t IntRndm()
generate a 64 bit integer number
double Rndm_impl()
implementation function to generrate the random number
MixMaxEngine(uint64_t seed=1)
rng_state_t * fRngState
Definition: MixMaxEngine.h:88
const Int_t n
Definition: legend1.C:16