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


                                                   >>   1 // $Id:$
  1 // -*- C++ -*-                                      2 // -*- C++ -*-
  2 //                                                  3 //
  3 // -------------------------------------------      4 // -----------------------------------------------------------------------
  4 //                           Hep Random             5 //                           Hep Random
  5 //                        --- DualRand ---          6 //                        --- DualRand ---
  6 //                        class header file         7 //                        class header file
  7 // -------------------------------------------      8 // -----------------------------------------------------------------------
  8 //                                                  9 //                  
  9 //  Canopy random number generator DualRand        10 //  Canopy random number generator DualRand
 10 //  Re-written as C++ routine for 32-bit ints      11 //  Re-written as C++ routine for 32-bit ints MF 1/26/98
 11 //                                                 12 //
 12 //  Exclusive or of a feedback shift register      13 //  Exclusive or of a feedback shift register and integer congruence
 13 //  random number generator.  The feedback shi     14 //  random number generator.  The feedback shift register uses offsets
 14 //  127 and 97.  The integer congruence genera     15 //  127 and 97.  The integer congruence generator uses a different
 15 //  multiplier for each stream.  The multiplie     16 //  multiplier for each stream.  The multipliers are chosen to give
 16 //  full period and maximum "potency" for modu     17 //  full period and maximum "potency" for modulo 2^32.  The period of
 17 //  the combined random number generator is 2^     18 //  the combined random number generator is 2^159 - 2^32, and the
 18 //  sequences are different for each stream (n     19 //  sequences are different for each stream (not just started in a
 19 //  different place).                              20 //  different place).
 20 //                                                 21 //
 21 // ===========================================     22 // =======================================================================
 22 //  Canopy random number generator DualRand.       23 //  Canopy random number generator DualRand.
 23 //  Doug Toussaint   5/25/88                       24 //  Doug Toussaint   5/25/88                     
 24 //  Optimized by GMH 7/26/88                       25 //  Optimized by GMH 7/26/88                     
 25 //  Optimized by GMH 7/26/88                       26 //  Optimized by GMH 7/26/88                     
 26 //  Repaired  by GMH 12/1/88 to update modular     27 //  Repaired  by GMH 12/1/88 to update modular congruence state            
 27 //  Put into ranlib by GMH 6/23/89                 28 //  Put into ranlib by GMH 6/23/89                   
 28 //  Re-written as C++ routine for 32-bit ints      29 //  Re-written as C++ routine for 32-bit ints MF 1/26/98             
 29 //  Re-written for CLHEP package       KLS 6/0     30 //  Re-written for CLHEP package       KLS 6/04/98             
 30 //  Removed pow() from flat method for speed K     31 //  Removed pow() from flat method for speed KLS 7/21/98             
 31 //  Ken Smith    - Added conversion operators:     32 //  Ken Smith    - Added conversion operators:  6th Aug 1998             
 32 //  Mark Fischler    methods for distrib. inst     33 //  Mark Fischler    methods for distrib. instance save/restore 12/8/04    
 33 //  Mark Fischler    methods for anonymous sav     34 //  Mark Fischler    methods for anonymous save/restore 12/27/04    
 34 // Mark Fischler  - methods for vector save/re     35 // Mark Fischler  - methods for vector save/restore 3/7/05    
 35 // ===========================================     36 // =======================================================================
 36                                                    37 
 37                                                    38 
 38 #ifndef DualRand_h                                 39 #ifndef DualRand_h
 39 #define DualRand_h                                 40 #define DualRand_h
 40                                                    41 
 41 #include "CLHEP/Random/RandomEngine.h"             42 #include "CLHEP/Random/RandomEngine.h"
 42                                                    43 
 43 namespace CLHEP {                                  44 namespace CLHEP {
 44                                                    45 
 45 /**                                                46 /**
 46  * @author                                         47  * @author
 47  * @ingroup random                                 48  * @ingroup random
 48  */                                                49  */
 49 class DualRand: public HepRandomEngine {           50 class DualRand: public HepRandomEngine {
 50                                                    51 
 51 public:                                            52 public:
 52                                                    53 
 53   DualRand();                                      54   DualRand();
 54   DualRand(long seed);                             55   DualRand(long seed);
 55   DualRand(std::istream & is);                     56   DualRand(std::istream & is);
 56   DualRand(int rowIndex, int colIndex);            57   DualRand(int rowIndex, int colIndex);
 57   virtual ~DualRand();                             58   virtual ~DualRand();
 58                                                    59 
 59   // let the compiler generate the copy constr     60   // let the compiler generate the copy constructors
 60   //DualRand(const DualRand & p);                  61   //DualRand(const DualRand & p);
 61   //DualRand & operator=(const DualRand & p);      62   //DualRand & operator=(const DualRand & p);
 62                                                    63 
 63   double flat();                                   64   double flat();
 64   // Returns a pseudo random number between 0      65   // Returns a pseudo random number between 0 and 1 
 65   // (excluding the end points)                    66   // (excluding the end points)
 66                                                    67 
 67   void flatArray(const int size, double * vect     68   void flatArray(const int size, double * vect);
 68   // Fills an array "vect" of specified size w     69   // Fills an array "vect" of specified size with flat random values.
 69                                                    70 
 70   void setSeed(long seed, int);                    71   void setSeed(long seed, int);
 71   // Sets the state of the algorithm according     72   // Sets the state of the algorithm according to seed.
 72                                                    73 
 73   void setSeeds(const long * seeds, int);          74   void setSeeds(const long * seeds, int);
 74   // Sets the state of the algorithm according     75   // Sets the state of the algorithm according to the zero-terminated 
 75   // array of seeds.                               76   // array of seeds.
 76                                                    77 
 77   void saveStatus( const char filename[] = "Du     78   void saveStatus( const char filename[] = "DualRand.conf") const;
 78   // Saves on named file the current engine st     79   // Saves on named file the current engine status.
 79                                                    80 
 80   void restoreStatus( const char filename[] =      81   void restoreStatus( const char filename[] = "DualRand.conf" );
 81   // Reads from named file the last saved engi     82   // Reads from named file the last saved engine status and restores it.
 82                                                    83 
 83   void showStatus() const;                         84   void showStatus() const;
 84   // Dumps the current engine status on the sc     85   // Dumps the current engine status on the screen.
 85                                                    86 
 86   operator double();        // Returns same as <<  87   operator float();      // flat value, without worrying about filling bits
 87   operator float();         // flat value, wit << 
 88   operator unsigned int();  // 32-bit flat val     88   operator unsigned int();  // 32-bit flat value, quickest of all
 89                                                    89 
 90   virtual std::ostream & put (std::ostream & o     90   virtual std::ostream & put (std::ostream & os) const;
 91   virtual std::istream & get (std::istream & i     91   virtual std::istream & get (std::istream & is);
 92   static  std::string beginTag ( );                92   static  std::string beginTag ( );
 93   virtual std::istream & getState ( std::istre     93   virtual std::istream & getState ( std::istream & is );
 94                                                    94     
 95   std::string name() const;                        95   std::string name() const;
 96   static std::string engineName() {return "Dua     96   static std::string engineName() {return "DualRand";}
 97                                                    97 
 98   std::vector<unsigned long> put () const;         98   std::vector<unsigned long> put () const;
 99   bool get (const std::vector<unsigned long> &     99   bool get (const std::vector<unsigned long> & v);
100   bool getState (const std::vector<unsigned lo    100   bool getState (const std::vector<unsigned long> & v);
101                                                   101   
102   static const unsigned int VECTOR_STATE_SIZE     102   static const unsigned int VECTOR_STATE_SIZE = 9;
103                                                   103 
104 private:                                          104 private:
105                                                   105 
                                                   >> 106   static int numEngines;
                                                   >> 107 
106   // This generator is composed of two others     108   // This generator is composed of two others combined:
107                                                   109 
108   class Tausworthe {                              110   class Tausworthe {
109   public:                                         111   public:
110     Tausworthe();                                 112     Tausworthe();
111     Tausworthe(unsigned int seed);                113     Tausworthe(unsigned int seed);
112     operator unsigned int();                      114     operator unsigned int();
113     void put(std::ostream & os) const;            115     void put(std::ostream & os) const;
114     void put(std::vector<unsigned long> & v) c    116     void put(std::vector<unsigned long> & v) const;
115     void get(std::istream & is);                  117     void get(std::istream & is);
116     bool get(std::vector<unsigned long>::const    118     bool get(std::vector<unsigned long>::const_iterator & iv);
117   private:                                        119   private:
118     int wordIndex;                                120     int wordIndex;
119     unsigned int words[4];                        121     unsigned int words[4];
120   }; // Tausworthe                                122   }; // Tausworthe
121                                                   123 
122   class IntegerCong {                             124   class IntegerCong {
123   public:                                         125   public:
124     IntegerCong();                                126     IntegerCong();
125     IntegerCong(unsigned int seed, int streamN    127     IntegerCong(unsigned int seed, int streamNumber);
126     operator unsigned int();                      128     operator unsigned int();
127     void put(std::ostream & os) const;            129     void put(std::ostream & os) const;
128     void put(std::vector<unsigned long> & v) c    130     void put(std::vector<unsigned long> & v) const;
129     void get(std::istream & is);                  131     void get(std::istream & is);
130     bool get(std::vector<unsigned long>::const    132     bool get(std::vector<unsigned long>::const_iterator & iv);
131   private:                                        133   private:
132     unsigned int state, multiplier, addend;       134     unsigned int state, multiplier, addend;
133   }; // IntegerCong                               135   }; // IntegerCong
134                                                   136 
135   int numEngines;                              << 
136   Tausworthe  tausworthe;                         137   Tausworthe  tausworthe;
137   IntegerCong integerCong;                        138   IntegerCong integerCong;
138                                                   139 
139 }; // DualRand                                    140 }; // DualRand
140                                                   141 
141 }  // namespace CLHEP                             142 }  // namespace CLHEP
142                                                   143 
143 #endif // DualRand_h                              144 #endif // DualRand_h
144                                                   145