Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MixMaxRng.h
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- MixMaxRng ---
7 // class header file
8 // -----------------------------------------------------------------------
9 //
10 // This file interfaces the PseudoRandom Number Generator
11 // proposed by:
12 // N.Z. Akopov, G.K.Saviddy & N.G. Ter-Arutyunian
13 // "Matrix Generator of Pseudorandom Numbers",
14 // J.Compt.Phy. 97, 573 (1991)
15 // Preprint: EPI-867(18)-86, Yerevan June 1986.
16 // G. Savvidy & N. Savvidy
17 // "On the Monte Carlo Simulation of Physical Systems",
18 // J.Comput.Phys. 97 (1991) 566
19 
20 // =======================================================================
21 // Implementation by Konstantin Savvidy - 2004-2015
22 // Release 0.99 and later: released under the LGPL license version 3.0
23 // =======================================================================
24 // CLHEP interface implemented by
25 // J. Apostolakis, G. Cosmo & K. Savvidy - Created: 6th July 2015
26 // CLHEP interface released under the LGPL license version 3.0
27 // =======================================================================
28 
29 #ifndef MixMaxRng_h
30 #define MixMaxRng_h 1
31 
33 #include "CLHEP/Random/mixmax.h"
34 
35 namespace CLHEP {
36 
41 class MixMaxRng: public HepRandomEngine {
42 
43 public:
44 
45  MixMaxRng(std::istream& is);
46  MixMaxRng();
47  MixMaxRng(long seed);
48  MixMaxRng(int rowIndex, int colIndex);
49  virtual ~MixMaxRng();
50  // Constructor and destructor.
51 
52  MixMaxRng(const MixMaxRng& rng);
53  MixMaxRng& operator=(const MixMaxRng& rng);
54  // Copy constructor and assignment operator.
55 
56  double flat();
57  // Returns a pseudo random number between 0 and 1
58  // (excluding the zero: in (0,1] )
59  // smallest number which it will give is approximately 10^-19
60 
61  void flatArray (const int size, double* vect);
62  // Fills the array "vect" of specified size with flat random values.
63 
64  void setSeed(long seed, int dum=0);
65  // Sets the state of the algorithm according to seed.
66 
67  void setSeeds(const long * seeds, int seedNum=0);
68  // Sets the initial state of the engine according to the array of between one and four 32-bit seeds.
69  // If the size of long is greater on the platform, only the lower 32-bits are used.
70  // Streams created from seeds differing by at least one bit somewhere are guaranteed absolutely
71  // to be independent and non-colliding for at least the next 10^100 random numbers
72 
73  void saveStatus( const char filename[] = "MixMaxRngState.conf" ) const;
74  // Saves the the current engine state in the file given, by default MixMaxRngState.conf
75 
76  void restoreStatus( const char filename[] = "MixMaxRngState.conf" );
77  // Reads a valid engine state from a given file, by default MixMaxRngState.conf
78  // and restores it.
79 
80  void showStatus() const;
81  // Dumps the engine status on the screen.
82 
83  operator unsigned int();
84  // 32-bit flat
85 
86  virtual std::ostream & put (std::ostream & os) const;
87  virtual std::istream & get (std::istream & is);
88  static std::string beginTag ( );
89  virtual std::istream & getState ( std::istream & is );
90 
91  std::string name() const;
92  static std::string engineName() {return "MixMaxRng";}
93 
94  std::vector<unsigned long> put () const;
95  bool get (const std::vector<unsigned long> & v);
96  bool getState (const std::vector<unsigned long> & v);
97 
98  static const unsigned int VECTOR_STATE_SIZE = 2*N+4; // 2N+4 for MIXMAX
99 
100 private:
101 
102  // Pointer to the current status of the generator.
103  rng_state_st* fRngState;
104 };
105 
106 } // namespace CLHEP
107 
108 #endif
void restoreStatus(const char filename[]="MixMaxRngState.conf")
Definition: MixMaxRng.cc:120
const int N
Definition: mixmax.h:43
static std::string engineName()
Definition: MixMaxRng.h:92
virtual std::istream & getState(std::istream &is)
Definition: MixMaxRng.cc:255
MixMaxRng & operator=(const MixMaxRng &rng)
Definition: MixMaxRng.cc:87
void setSeeds(const long *seeds, int seedNum=0)
Definition: MixMaxRng.cc:153
static std::string beginTag()
Definition: MixMaxRng.cc:250
std::vector< unsigned long > put() const
Definition: MixMaxRng.cc:216
static const unsigned int VECTOR_STATE_SIZE
Definition: MixMaxRng.h:98
virtual ~MixMaxRng()
Definition: MixMaxRng.cc:74
long seed
Definition: chem4.cc:68
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
std::string name() const
Definition: MixMaxRng.cc:51
tuple v
Definition: test.py:18
void flatArray(const int size, double *vect)
Definition: MixMaxRng.cc:185
void setSeed(long seed, int dum=0)
Definition: MixMaxRng.cc:136
void saveStatus(const char filename[]="MixMaxRngState.conf") const
Definition: MixMaxRng.cc:107
void showStatus() const
Definition: MixMaxRng.cc:125