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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/include/CLHEP/Random/MTwistEngine.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Random/MTwistEngine.h (Version 10.0)


                                                   >>   1 // $Id:$
  1 // -*- C++ -*-                                      2 // -*- C++ -*-
  2 //                                                  3 //
  3 // -------------------------------------------      4 // -----------------------------------------------------------------------
  4 //                             HEP Random           5 //                             HEP Random
  5 //                        --- MTwistEngine ---      6 //                        --- MTwistEngine ---
  6 //                          class header file       7 //                          class header file
  7 // -------------------------------------------      8 // -----------------------------------------------------------------------
  8 // A "fast, compact, huge-period generator" ba      9 // A "fast, compact, huge-period generator" based on M. Matsumoto and 
  9 // T. Nishimura, "Mersenne Twister: A 623-dime     10 // T. Nishimura, "Mersenne Twister: A 623-dimensionally equidistributed 
 10 // uniform pseudorandom number generator", to      11 // uniform pseudorandom number generator", to appear in ACM Trans. on
 11 // Modeling and Computer Simulation.  It is a      12 // Modeling and Computer Simulation.  It is a twisted GFSR generator
 12 // with a Mersenne-prime period of 2^19937-1,      13 // with a Mersenne-prime period of 2^19937-1, uniform on open interval (0,1)
 13 // For further information, see http://www.mat     14 // For further information, see http://www.math.keio.ac.jp/~matumoto/emt.html
 14 // ===========================================     15 // =======================================================================
 15 // Ken Smith      - Started initial draft: 14t     16 // Ken Smith      - Started initial draft: 14th Jul 1998
 16 //                - Optimized to get pow() out     17 //                - Optimized to get pow() out of flat() method: 21st Jul
 17 //                - Added conversion operators     18 //                - Added conversion operators:  6th Aug 1998
 18 // M Fischler   - Changes in way powers of two     19 // M Fischler   - Changes in way powers of two are kept: 16-Sep-1998
 19 // Mark Fischler  - Methods for distrib. insta     20 // Mark Fischler  - Methods for distrib. instance save/restore 12/8/04    
 20 // Mark Fischler    methods for anonymous save     21 // Mark Fischler    methods for anonymous save/restore 12/27/04    
 21 // ===========================================     22 // =======================================================================
 22                                                    23 
 23 #ifndef MTwistEngine_h                             24 #ifndef MTwistEngine_h
 24 #define MTwistEngine_h                             25 #define MTwistEngine_h
 25                                                    26 
 26 #include "CLHEP/Random/RandomEngine.h"             27 #include "CLHEP/Random/RandomEngine.h"
 27                                                    28 
 28 namespace CLHEP {                                  29 namespace CLHEP {
 29                                                    30 
 30 /**                                                31 /**
 31  * @author                                         32  * @author
 32  * @ingroup random                                 33  * @ingroup random
 33  */                                                34  */
 34 class MTwistEngine : public HepRandomEngine {      35 class MTwistEngine : public HepRandomEngine {
 35                                                    36 
 36 public:                                            37 public:
 37                                                    38 
 38   MTwistEngine();                                  39   MTwistEngine();
 39   MTwistEngine( long seed );                       40   MTwistEngine( long seed );
 40   MTwistEngine( int rowIndex, int colIndex );      41   MTwistEngine( int rowIndex, int colIndex );
 41   MTwistEngine( std::istream & is );               42   MTwistEngine( std::istream & is );
 42   virtual ~MTwistEngine();                         43   virtual ~MTwistEngine();
 43   // Constructors and destructor.                  44   // Constructors and destructor.
 44                                                    45 
 45   double flat();                                   46   double flat();
 46   // Returns a pseudo random number between 0      47   // Returns a pseudo random number between 0 and 1 (excluding the end points).
 47                                                    48 
 48   void flatArray(const int size, double* vect)     49   void flatArray(const int size, double* vect);
 49   // Fills an array "vect" of specified size w     50   // Fills an array "vect" of specified size with flat random values.
 50                                                    51 
 51   void setSeed(long seed, int);                    52   void setSeed(long seed, int);
 52   // Sets the state of the algorithm according     53   // Sets the state of the algorithm according to seed.
 53                                                    54 
 54   void setSeeds(const long * seeds, int);          55   void setSeeds(const long * seeds, int);
 55   // Sets the state of the algorithm according     56   // Sets the state of the algorithm according to the zero terminated
 56   // array of seeds. It is allowed to ignore o     57   // array of seeds. It is allowed to ignore one or many seeds in this array.
 57                                                    58 
 58   void saveStatus( const char filename[] = "MT     59   void saveStatus( const char filename[] = "MTwist.conf") const;
 59   // Saves the current engine status in the na     60   // Saves the current engine status in the named file
 60                                                    61 
 61   void restoreStatus( const char filename[] =      62   void restoreStatus( const char filename[] = "MTwist.conf" );
 62   // Reads from named file the the last saved      63   // Reads from named file the the last saved engine status and restores it.
 63                                                    64 
 64   void showStatus() const;                         65   void showStatus() const;
 65   // Dumps the current engine status on the sc     66   // Dumps the current engine status on the screen.
 66                                                    67 
 67   operator double();       // Returns same as  <<  68   operator float();     // returns flat, without worrying about filling bits
 68   operator float();        // returns flat, wi << 
 69   operator unsigned int(); // 32-bit flat, qui     69   operator unsigned int(); // 32-bit flat, quickest of all
 70                                                    70 
 71   virtual std::ostream & put (std::ostream & o     71   virtual std::ostream & put (std::ostream & os) const;
 72   virtual std::istream & get (std::istream & i     72   virtual std::istream & get (std::istream & is);
 73   static  std::string beginTag ( );                73   static  std::string beginTag ( );
 74   virtual std::istream & getState ( std::istre     74   virtual std::istream & getState ( std::istream & is );
 75                                                    75 
 76   std::string name() const;                        76   std::string name() const;
 77   static std::string engineName() {return "MTw     77   static std::string engineName() {return "MTwistEngine";}
 78                                                    78 
 79   std::vector<unsigned long> put () const;         79   std::vector<unsigned long> put () const;
 80   bool get (const std::vector<unsigned long> &     80   bool get (const std::vector<unsigned long> & v);
 81   bool getState (const std::vector<unsigned lo     81   bool getState (const std::vector<unsigned long> & v);
 82                                                    82 
 83   static const unsigned int VECTOR_STATE_SIZE      83   static const unsigned int VECTOR_STATE_SIZE = 626;
 84                                                    84   
 85 private:                                           85 private:
 86                                                    86 
 87   unsigned int mt[624];                            87   unsigned int mt[624];
 88   int count624;                                    88   int count624;
 89                                                    89 
 90   enum{ NminusM = 227, M = 397, N = 624};          90   enum{ NminusM = 227, M = 397, N = 624};
                                                   >>  91   static int numEngines;
                                                   >>  92   static int maxIndex;
 91                                                    93 
 92 }; // MTwistEngine                                 94 }; // MTwistEngine
 93                                                    95 
 94 }  // namespace CLHEP                              96 }  // namespace CLHEP
 95                                                    97 
 96 #endif // MTwistEngine_h                           98 #endif // MTwistEngine_h
 97                                                    99