Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
MTwistEngine.h
이 파일의 문서화 페이지로 가기
1 // $Id:$
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 
28 
29 namespace CLHEP {
30 
35 class MTwistEngine : public HepRandomEngine {
36 
37 public:
38 
39  MTwistEngine();
40  MTwistEngine( long seed );
41  MTwistEngine( int rowIndex, int colIndex );
42  MTwistEngine( std::istream & is );
43  virtual ~MTwistEngine();
44  // Constructors and destructor.
45 
46  double flat();
47  // Returns a pseudo random number between 0 and 1 (excluding the end points).
48 
49  void flatArray(const int size, double* vect);
50  // Fills an array "vect" of specified size with flat random values.
51 
52  void setSeed(long seed, int);
53  // Sets the state of the algorithm according to seed.
54 
55  void setSeeds(const long * seeds, int);
56  // Sets the state of the algorithm according to the zero terminated
57  // array of seeds. It is allowed to ignore one or many seeds in this array.
58 
59  void saveStatus( const char filename[] = "MTwist.conf") const;
60  // Saves the current engine status in the named file
61 
62  void restoreStatus( const char filename[] = "MTwist.conf" );
63  // Reads from named file the the last saved engine status and restores it.
64 
65  void showStatus() const;
66  // Dumps the current engine status on the screen.
67 
68  operator double(); // Returns same as flat()
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 
93 }; // MTwistEngine
94 
95 } // namespace CLHEP
96 
97 #endif // MTwistEngine_h
void showStatus() const
static std::string engineName()
Definition: MTwistEngine.h:78
void setSeed(long seed, int)
virtual std::istream & getState(std::istream &is)
long seed
Definition: chem4.cc:68
void saveStatus(const char filename[]="MTwist.conf") const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void restoreStatus(const char filename[]="MTwist.conf")
unsigned int mt[624]
Definition: MTwistEngine.h:88
static const unsigned int VECTOR_STATE_SIZE
Definition: MTwistEngine.h:84
std::string name() const
Definition: MTwistEngine.cc:62
std::vector< unsigned long > put() const
static std::string beginTag()
void setSeeds(const long *seeds, int)
void flatArray(const int size, double *vect)