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


                                                   >>   1 // $Id:$
  1 // -*- C++ -*-                                      2 // -*- C++ -*-
  2 //                                                  3 //
  3 // -------------------------------------------      4 // -----------------------------------------------------------------------
  4 //                             HEP Random           5 //                             HEP Random
  5 //                         --- RanecuEngine --      6 //                         --- RanecuEngine ---
  6 //                          class header file       7 //                          class header file
  7 // -------------------------------------------      8 // -----------------------------------------------------------------------
  8 // This file is part of Geant4 (simulation too      9 // This file is part of Geant4 (simulation toolkit for HEP).
  9 //                                                 10 //
 10 // RANECU Random Engine - algorithm originally     11 // RANECU Random Engine - algorithm originally written in FORTRAN77
 11 //                        as part of the MATHL     12 //                        as part of the MATHLIB HEP library.
 12 // The initialisation is carried out using a M     13 // The initialisation is carried out using a Multiplicative Congruential
 13 // generator using formula constants of L'Ecuy     14 // generator using formula constants of L'Ecuyer as described in "F.James,
 14 // Comp. Phys. Comm. 60 (1990) 329-344".           15 // Comp. Phys. Comm. 60 (1990) 329-344".
 15 // Seeds are taken from a seed table given an      16 // Seeds are taken from a seed table given an index, the getSeed() method
 16 // returns the current index in the seed table     17 // returns the current index in the seed table, the getSeeds() method
 17 // returns a pointer to the couple of seeds st     18 // returns a pointer to the couple of seeds stored in the local table of
 18 // seeds at the current index.                     19 // seeds at the current index.
 19                                                    20 
 20 // ===========================================     21 // =======================================================================
 21 // Gabriele Cosmo - Created: 2nd February 1996     22 // Gabriele Cosmo - Created: 2nd February 1996
 22 //                - Minor corrections: 31st Oc     23 //                - Minor corrections: 31st October 1996
 23 //                - Added methods for engine s     24 //                - Added methods for engine status: 19th November 1996
 24 //                - setSeed() now has default      25 //                - setSeed() now has default dummy argument
 25 //                  set to zero: 11th July 199     26 //                  set to zero: 11th July 1997
 26 //                - Added default index to set     27 //                - Added default index to setSeeds(): 16th Oct 1997
 27 // J.Marraffino   - Added stream operators and     28 // J.Marraffino   - Added stream operators and related constructor.
 28 //                  Added automatic seed selec     29 //                  Added automatic seed selection from seed table and
 29 //                  engine counter: 16th Feb 1     30 //                  engine counter: 16th Feb 1998
 30 // Ken Smith      - Added conversion operators     31 // Ken Smith      - Added conversion operators:  6th Aug 1998
 31 // Mark Fischler    Methods for distrib. insta     32 // Mark Fischler    Methods for distrib. instance save/restore 12/8/04    
 32 // Mark Fischler    methods for anonymous save     33 // Mark Fischler    methods for anonymous save/restore 12/27/04    
 33 // ===========================================     34 // =======================================================================
 34                                                    35 
 35 #ifndef RanecuEngine_h                             36 #ifndef RanecuEngine_h
 36 #define RanecuEngine_h 1                           37 #define RanecuEngine_h 1
 37                                                    38 
 38 #include "CLHEP/Random/RandomEngine.h"             39 #include "CLHEP/Random/RandomEngine.h"
 39                                                    40 
 40 namespace CLHEP {                                  41 namespace CLHEP {
 41                                                    42 
 42 /**                                                43 /**
 43  * @author <Gabriele.Cosmo@cern.ch>                44  * @author <Gabriele.Cosmo@cern.ch>
 44  * @ingroup random                                 45  * @ingroup random
 45  */                                                46  */
 46 class RanecuEngine : public HepRandomEngine {      47 class RanecuEngine : public HepRandomEngine {
 47                                                    48 
 48 public:                                            49 public:
 49                                                    50 
 50   RanecuEngine(std::istream& is);                  51   RanecuEngine(std::istream& is);
 51   RanecuEngine();                                  52   RanecuEngine();
 52   RanecuEngine(int index);                         53   RanecuEngine(int index);
 53   virtual ~RanecuEngine();                         54   virtual ~RanecuEngine();
 54   // Constructors and destructor.                  55   // Constructors and destructor.
 55                                                    56 
 56   double flat();                                   57   double flat();
 57   // Returns a pseudo random number between 0      58   // Returns a pseudo random number between 0 and 1 
 58   // (excluding the end points)                    59   // (excluding the end points)
 59                                                    60 
 60   void flatArray (const int size, double* vect     61   void flatArray (const int size, double* vect);
 61   // Fills an array "vect" of specified size w     62   // Fills an array "vect" of specified size with flat random values.
 62                                                    63 
 63   void setIndex (long index);                      64   void setIndex (long index);
 64   // Sets the state of the algorithm according     65   // Sets the state of the algorithm according to "index", the position
 65   // in the local table of seeds.                  66   // in the local table of seeds.
 66                                                    67  
 67   void setSeed (long index, int dum=0);            68   void setSeed (long index, int dum=0);
 68   // Resets the state of the algorithm accordi     69   // Resets the state of the algorithm according to "index", the position
 69   // in the static table of seeds stored in He     70   // in the static table of seeds stored in HepRandom.
 70                                                    71 
 71   void setSeeds (const long* seeds, int index=     72   void setSeeds (const long* seeds, int index=-1);
 72   // Sets the state of the algorithm according     73   // Sets the state of the algorithm according to the array of seeds
 73   // "seeds" containing two seed values to be      74   // "seeds" containing two seed values to be stored in the local table at
 74   // "index" position.                             75   // "index" position.
 75                                                    76 
 76   void saveStatus( const char filename[] = "Ra     77   void saveStatus( const char filename[] = "Ranecu.conf" ) const;
 77   // Saves on file Ranecu.conf the current eng     78   // Saves on file Ranecu.conf the current engine status.
 78                                                    79 
 79   void restoreStatus( const char filename[] =      80   void restoreStatus( const char filename[] = "Ranecu.conf" );
 80   // Reads from file Ranecu.conf the last save     81   // Reads from file Ranecu.conf the last saved engine status
 81   // and restores it.                              82   // and restores it.
 82                                                    83 
 83   void showStatus() const;                         84   void showStatus() const;
 84   // Dumps the engine status on the screen.        85   // Dumps the engine status on the screen.
 85                                                    86 
 86   operator double();                           << 
 87   // Returns same as flat()                    << 
 88   operator float();                            << 
 89   // less precise flat, faster if possible     << 
 90   operator unsigned int();                         87   operator unsigned int();
 91   // 32-bit int flat, faster in this case          88   // 32-bit int flat, faster in this case
 92                                                    89 
 93   virtual std::ostream & put (std::ostream & o     90   virtual std::ostream & put (std::ostream & os) const;
 94   virtual std::istream & get (std::istream & i     91   virtual std::istream & get (std::istream & is);
 95   static  std::string beginTag ( );                92   static  std::string beginTag ( );
 96   virtual std::istream & getState ( std::istre     93   virtual std::istream & getState ( std::istream & is );
 97                                                    94 
 98   std::string name() const;                        95   std::string name() const;
 99   static std::string engineName() {return "Ran     96   static std::string engineName() {return "RanecuEngine";}
100                                                    97 
101   std::vector<unsigned long> put () const;         98   std::vector<unsigned long> put () const;
102   bool get (const std::vector<unsigned long> &     99   bool get (const std::vector<unsigned long> & v);
103   bool getState (const std::vector<unsigned lo    100   bool getState (const std::vector<unsigned long> & v);
104                                                   101   
105 protected:                                        102 protected:
106                                                   103 
107   // Suggested L'ecuyer coefficients for porta    104   // Suggested L'ecuyer coefficients for portable 32 bits generators.
108                                                   105   
109   static const int ecuyer_a = 40014;              106   static const int ecuyer_a = 40014;
110   static const int ecuyer_b = 53668;              107   static const int ecuyer_b = 53668;
111   static const int ecuyer_c = 12211;              108   static const int ecuyer_c = 12211;
112   static const int ecuyer_d = 40692;              109   static const int ecuyer_d = 40692;
113   static const int ecuyer_e = 52774;              110   static const int ecuyer_e = 52774;
114   static const int ecuyer_f = 3791;               111   static const int ecuyer_f = 3791;
115   static const int shift1   = 2147483563;         112   static const int shift1   = 2147483563;
116   static const int shift2   = 2147483399;         113   static const int shift2   = 2147483399;
117                                                   114 
118   static const unsigned int VECTOR_STATE_SIZE     115   static const unsigned int VECTOR_STATE_SIZE = 4;
119                                                   116   
120 private:                                          117 private:
121                                                   118 
122   // private method used to mitigate the effec    119   // private method used to mitigate the effects of using a lookup table
123   void further_randomize (int seq, int col, in    120   void further_randomize (int seq, int col, int index, int modulus);
124                                                   121 
125   // Members defining the current state of the    122   // Members defining the current state of the generator.
126                                                   123 
127   static const int maxSeq = 215;                  124   static const int maxSeq = 215;
128   long table[215][2];                             125   long table[215][2];
129   int seq;                                        126   int seq;
130                                                   127 
131 };                                                128 };
132                                                   129 
133 }  // namespace CLHEP                             130 }  // namespace CLHEP
134                                                   131 
135 #endif                                            132 #endif
136                                                   133