CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Random/Random/MTwistEngine.h
Go to the documentation of this file.
1 // $Id: MTwistEngine.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- MTwistEngine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // A "fast, compact, huge-period generator" based on M. Matsumoto and
10 // T. Nishimura, "Mersenne Twister: A 623-dimensionally equidistributed
11 // uniform pseudorandom number generator", to appear in ACM Trans. on
12 // Modeling and Computer Simulation. It is a twisted GFSR generator
13 // with a Mersenne-prime period of 2^19937-1, uniform on open interval (0,1)
14 // For further information, see http://www.math.keio.ac.jp/~matumoto/emt.html
15 // =======================================================================
16 // Ken Smith - Started initial draft: 14th Jul 1998
17 // - Optimized to get pow() out of flat() method: 21st Jul
18 // - Added conversion operators: 6th Aug 1998
19 // M Fischler - Changes in way powers of two are kept: 16-Sep-1998
20 // Mark Fischler - Methods for distrib. instance save/restore 12/8/04
21 // Mark Fischler methods for anonymous save/restore 12/27/04
22 // =======================================================================
23 
24 #ifndef MTwistEngine_h
25 #define MTwistEngine_h
26 
27 #include "CLHEP/Random/defs.h"
28 #include "CLHEP/Random/RandomEngine.h"
29 
30 namespace CLHEP {
31 
36 class MTwistEngine : public HepRandomEngine {
37 
38 public:
39 
40  MTwistEngine();
41  MTwistEngine( long seed );
42  MTwistEngine( int rowIndex, int colIndex );
43  MTwistEngine( std::istream & is );
44  virtual ~MTwistEngine();
45  // Constructors and destructor.
46 
47  double flat();
48  // Returns a pseudo random number between 0 and 1 (excluding the end points).
49 
50  void flatArray(const int size, double* vect);
51  // Fills an array "vect" of specified size with flat random values.
52 
53  void setSeed(long seed, int);
54  // Sets the state of the algorithm according to seed.
55 
56  void setSeeds(const long * seeds, int);
57  // Sets the state of the algorithm according to the zero terminated
58  // array of seeds. It is allowed to ignore one or many seeds in this array.
59 
60  void saveStatus( const char filename[] = "MTwist.conf") const;
61  // Saves the current engine status in the named file
62 
63  void restoreStatus( const char filename[] = "MTwist.conf" );
64  // Reads from named file the the last saved engine status and restores it.
65 
66  void showStatus() const;
67  // Dumps the current engine status on the screen.
68 
69  operator float(); // returns flat, without worrying about filling bits
70  operator unsigned int(); // 32-bit flat, quickest of all
71 
72  virtual std::ostream & put (std::ostream & os) const;
73  virtual std::istream & get (std::istream & is);
74  static std::string beginTag ( );
75  virtual std::istream & getState ( std::istream & is );
76 
77  std::string name() const;
78  static std::string engineName() {return "MTwistEngine";}
79 
80  std::vector<unsigned long> put () const;
81  bool get (const std::vector<unsigned long> & v);
82  bool getState (const std::vector<unsigned long> & v);
83 
84  static const unsigned int VECTOR_STATE_SIZE = 626;
85 
86 private:
87 
88  unsigned int mt[624];
89  int count624;
90 
91  enum{ NminusM = 227, M = 397, N = 624};
92  static int numEngines;
93  static int maxIndex;
94 
95 }; // MTwistEngine
96 
97 } // namespace CLHEP
98 
99 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
100 // backwards compatibility will be enabled ONLY in CLHEP 1.9
101 using namespace CLHEP;
102 #endif
103 
104 #endif // MTwistEngine_h
CLHEP::MTwistEngine::restoreStatus
void restoreStatus(const char filename[]="MTwist.conf")
Definition: MTwistEngine.cc:192
CLHEP::MTwistEngine::~MTwistEngine
virtual ~MTwistEngine()
Definition: MTwistEngine.cc:105
CLHEP::MTwistEngine::engineName
static std::string engineName()
Definition: Random/Random/MTwistEngine.h:78
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::MTwistEngine::flat
double flat()
Definition: MTwistEngine.cc:107
size
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
CLHEP
Definition: ClhepVersion.h:13
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
CLHEP::MTwistEngine::setSeeds
void setSeeds(const long *seeds, int)
Definition: MTwistEngine.cc:172
CLHEP::MTwistEngine::get
virtual std::istream & get(std::istream &is)
Definition: MTwistEngine.cc:311
CLHEP::MTwistEngine::MTwistEngine
MTwistEngine()
Definition: MTwistEngine.cc:58
CLHEP::MTwistEngine::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/MTwistEngine.h:84
seeds
Technical Maintenance Note for CLHEP Random Consequences of seeding JamesRandom with positive seed values greater than In the source code JamesRandom The usual way of seeding a generator is via the default which makes use of the table of seeds(with some trickery to ensure that the values won 't repeat after the table rows are exhausted). The trickery preserves the fact that sees are never negative(because the table values are never negative
CLHEP::MTwistEngine::beginTag
static std::string beginTag()
Definition: MTwistEngine.cc:329
CLHEP::MTwistEngine::getState
virtual std::istream & getState(std::istream &is)
Definition: MTwistEngine.cc:333
CLHEP::MTwistEngine::setSeed
void setSeed(long seed, int)
Definition: MTwistEngine.cc:144
CLHEP::MTwistEngine::put
std::vector< unsigned long > put() const
Definition: MTwistEngine.cc:301
CLHEP::MTwistEngine::flatArray
void flatArray(const int size, double *vect)
Definition: MTwistEngine.cc:140
CLHEP::MTwistEngine::showStatus
void showStatus() const
Definition: MTwistEngine.cc:207
CLHEP::MTwistEngine::name
std::string name() const
Definition: MTwistEngine.cc:53
CLHEP::MTwistEngine::saveStatus
void saveStatus(const char filename[]="MTwist.conf") const
Definition: MTwistEngine.cc:181