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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/Ranlux64Engine.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Random/Ranlux64Engine.h (Version 10.7)


  1 // -*- C++ -*-                                      1 // -*- C++ -*-
  2 //                                                  2 //
  3 // -------------------------------------------      3 // -----------------------------------------------------------------------
  4 //                             HEP Random           4 //                             HEP Random
  5 //                        --- Ranlux64Engine -      5 //                        --- Ranlux64Engine ---
  6 //                          class header file       6 //                          class header file
  7 // -------------------------------------------      7 // -----------------------------------------------------------------------
  8 // The algorithm for this random engine has be      8 // The algorithm for this random engine has been taken from the notes of 
  9 // a double-precision ranlux implementation by      9 // a double-precision ranlux implementation by Martin Luscher, dated 
 10 // November 1997.                                  10 // November 1997.
 11 //                                                 11 //
 12 // Like the previous ranlux generator, this on     12 // Like the previous ranlux generator, this one also has "luxury" levels,
 13 // determining how many pseudo-random numbers      13 // determining how many pseudo-random numbers are discarded for every 
 14 // twelve values used. Three levels are given,     14 // twelve values used. Three levels are given, with the note that Luscher
 15 // himself advocates only the highest two leve     15 // himself advocates only the highest two levels for this engine.
 16 //  level 0  (p=109):              Throw away      16 //  level 0  (p=109):              Throw away 109 values for every 12 used
 17 //  level 1  (p=202):   (default)  Throw away      17 //  level 1  (p=202):   (default)  Throw away 202 values for every 12 used
 18 //  level 2  (p=397):              Throw away      18 //  level 2  (p=397):              Throw away 397 values for every 12 used
 19 //                                                 19 //
 20 // The initialization is carried out using a M     20 // The initialization is carried out using a Multiplicative Congruential
 21 // generator using formula constants of L'Ecuy     21 // generator using formula constants of L'Ecuyer as described in "F.James,
 22 // Comp. Phys. Comm. 60 (1990) 329-344".           22 // Comp. Phys. Comm. 60 (1990) 329-344".
 23 // ===========================================     23 // =======================================================================
 24 // Ken Smith      - Created Initial draft: 14t     24 // Ken Smith      - Created Initial draft: 14th Jul 1998
 25 //                - Added conversion operators     25 //                - Added conversion operators:  6th Aug 1998
 26 // Mark Fischler                                   26 // Mark Fischler
 27 // 9/9/98   - Added update() routine to allow      27 // 9/9/98   - Added update() routine to allow computation of many at once
 28 //      - Replaced algorithm with jone exactly     28 //      - Replaced algorithm with jone exactly matching Luscher:
 29 //      48-bits generated                          29 //      48-bits generated
 30 //      skip n-12 instead of n numbers             30 //      skip n-12 instead of n numbers
 31 //      - Corrected protection agains overflow     31 //      - Corrected protection agains overflow
 32 // 12/8/04        - Methods for instance save/     32 // 12/8/04        - Methods for instance save/restore     
 33 // 12/27/04       - methods for anonymous save     33 // 12/27/04       - methods for anonymous save/restore 12/27/04    
 34 //                                                 34 //
 35 // ===========================================     35 // =======================================================================
 36                                                    36 
 37 #ifndef Ranlux64Engine_h                           37 #ifndef Ranlux64Engine_h
 38 #define Ranlux64Engine_h                           38 #define Ranlux64Engine_h
 39                                                    39 
 40 #include "CLHEP/Random/RandomEngine.h"             40 #include "CLHEP/Random/RandomEngine.h"
 41                                                    41 
 42 namespace CLHEP {                                  42 namespace CLHEP {
 43                                                    43 
 44 /**                                                44 /**
 45  * @author                                         45  * @author
 46  * @ingroup random                                 46  * @ingroup random
 47  */                                                47  */
 48 class Ranlux64Engine : public HepRandomEngine      48 class Ranlux64Engine : public HepRandomEngine {
 49                                                    49 
 50 public:                                            50 public:
 51                                                    51 
 52   Ranlux64Engine( std::istream& is );              52   Ranlux64Engine( std::istream& is );
 53   Ranlux64Engine();                                53   Ranlux64Engine();
 54   Ranlux64Engine( long seed, int lxr = 1 );    <<  54   Ranlux64Engine( long seed, int lux = 1 );
 55   Ranlux64Engine( int rowIndex, int colIndex,  <<  55   Ranlux64Engine( int rowIndex, int colIndex, int lux );
 56   virtual ~Ranlux64Engine();                       56   virtual ~Ranlux64Engine();
 57   // Constructors and destructor                   57   // Constructors and destructor
 58                                                    58 
 59   double flat();                                   59   double flat();
 60   // It returns a pseudo random number between     60   // It returns a pseudo random number between 0 and 1,
 61   // excluding the end points.                     61   // excluding the end points.
 62                                                    62 
 63   void flatArray (const int size, double* vect     63   void flatArray (const int size, double* vect);
 64   // Fills the array "vect" of specified size      64   // Fills the array "vect" of specified size with flat random values.
 65                                                    65 
 66   void setSeed(long seed, int lxr=1);          <<  66   void setSeed(long seed, int lux=1);
 67   // Sets the state of the algorithm according     67   // Sets the state of the algorithm according to seed.
 68                                                    68 
 69   void setSeeds(const long * seeds, int lxr=1) <<  69   void setSeeds(const long * seeds, int lux=1);
 70   // Sets the state of the algorithm according     70   // Sets the state of the algorithm according to the zero terminated
 71   // array of seeds.  Only the first seed is u     71   // array of seeds.  Only the first seed is used.
 72                                                    72 
 73   void saveStatus( const char filename[] = "Ra     73   void saveStatus( const char filename[] = "Ranlux64.conf" ) const;
 74   // Saves in named file the current engine st     74   // Saves in named file the current engine status.
 75                                                    75 
 76   void restoreStatus( const char filename[] =      76   void restoreStatus( const char filename[] = "Ranlux64.conf" );
 77   // Reads from named file the last saved engi     77   // Reads from named file the last saved engine status and restores it.
 78                                                    78 
 79   void showStatus() const;                         79   void showStatus() const;
 80   // Dumps the engine status on the screen.        80   // Dumps the engine status on the screen.
 81                                                    81 
 82   int getLuxury() const { return luxury; }         82   int getLuxury() const { return luxury; }
 83   // Gets the luxury level.                        83   // Gets the luxury level.
 84                                                    84 
 85   virtual std::ostream & put (std::ostream & o     85   virtual std::ostream & put (std::ostream & os) const;
 86   virtual std::istream & get (std::istream & i     86   virtual std::istream & get (std::istream & is);
 87   static  std::string beginTag ( );                87   static  std::string beginTag ( );
 88   virtual std::istream & getState ( std::istre     88   virtual std::istream & getState ( std::istream & is );
 89                                                    89 
 90   std::string name() const;                        90   std::string name() const;
 91   static std::string engineName() {return "Ran     91   static std::string engineName() {return "Ranlux64Engine";}
 92                                                    92 
 93   std::vector<unsigned long> put () const;         93   std::vector<unsigned long> put () const;
 94   bool get (const std::vector<unsigned long> &     94   bool get (const std::vector<unsigned long> & v);
 95   bool getState (const std::vector<unsigned lo     95   bool getState (const std::vector<unsigned long> & v);
 96                                                    96   
 97   static const unsigned int VECTOR_STATE_SIZE      97   static const unsigned int VECTOR_STATE_SIZE = 30;
 98                                                    98   
 99 private:                                           99 private:
100                                                   100 
101   void update();                                  101   void update();
102   void advance(int dozens);                       102   void advance(int dozens);
103                                                   103 
104   int pDiscard;     // separate sequence by p-    104   int pDiscard;     // separate sequence by p-r = p-12 discarded elements
105   int pDozens;      // pDiscard / 12;             105   int pDozens;      // pDiscard / 12;
106   int endIters;     // pDiscard % 12;             106   int endIters;     // pDiscard % 12;
107   int luxury;                                     107   int luxury;
108                                                   108 
109   int index;                                      109   int index;
110   double randoms[12]; // randoms [i] is the x[    110   double randoms[12]; // randoms [i] is the x[n-i] of Luscher's note
111   double carry;                                   111   double carry;
112                                                   112 
113 }; // Ranlux64Engine                              113 }; // Ranlux64Engine
114                                                   114 
115 }  // namespace CLHEP                             115 }  // namespace CLHEP
116                                                   116 
117 #endif // Ranlux64Engine_h                        117 #endif // Ranlux64Engine_h
118                                                   118