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


                                                   >>   1 // $Id:$
  1 // -*- C++ -*-                                      2 // -*- C++ -*-
  2 //                                                  3 //
  3 // -------------------------------------------      4 // -----------------------------------------------------------------------
  4 //                             HEP Random           5 //                             HEP Random
  5 //                          --- HepRandom ---       6 //                          --- HepRandom ---
  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 // It's a singleton instantiated by default wi     11 // It's a singleton instantiated by default within the HEP Random module.
 11 // It uses an instantiated HepJamesRandom engi     12 // It uses an instantiated HepJamesRandom engine as default algorithm
 12 // for pseudo-random number generation. HepRan     13 // for pseudo-random number generation. HepRandom defines a static private
 13 // data member theGenerator and a set of stati     14 // data member theGenerator and a set of static inlined methods to manipulate
 14 // it. By means of theGenerator the user can c     15 // it. By means of theGenerator the user can change the underlying engine
 15 // algorithm, get and set the seeds and use an     16 // algorithm, get and set the seeds and use any kind of defined random
 16 // distribution.                                   17 // distribution.
 17 // Distribution classes inherit from HepRandom     18 // Distribution classes inherit from HepRandom and define both static and
 18 // not-static interfaces.                          19 // not-static interfaces.
 19 // A static table of uncorrelated seeds is ava     20 // A static table of uncorrelated seeds is available in this class.
 20 // A static method "getTheTableSeeds()" is def     21 // A static method "getTheTableSeeds()" is defined to access a couple of
 21 // seeds at a given index in the table.            22 // seeds at a given index in the table.
 22                                                    23 
 23 // ===========================================     24 // =======================================================================
 24 // Gabriele Cosmo - Created: 5th Sep 1995          25 // Gabriele Cosmo - Created: 5th Sep 1995
 25 //                - Minor update: 17th May 199     26 //                - Minor update: 17th May 1996
 26 //                - Poisson now operates on do     27 //                - Poisson now operates on doubles : 31st Oct 1996
 27 //                - Added methods for engine s     28 //                - Added methods for engine status: 19th Nov 1996
 28 //                - Fixed default values to se     29 //                - Fixed default values to setTheSeed() and
 29 //                  setTheSeeds() static metho     30 //                  setTheSeeds() static methods: 16th Oct 1997
 30 //                - Modified HepRandom to act      31 //                - Modified HepRandom to act as a singleton, constructors
 31 //                  are kept public for backwa     32 //                  are kept public for backward compatibility. Added table
 32 //                  of seeds from HepRandomEng     33 //                  of seeds from HepRandomEngine: 19th Mar 1998
 33 //                - Relocated Poisson and Gaus     34 //                - Relocated Poisson and Gauss data and simplified
 34 //                  initialisation of static g     35 //                  initialisation of static generator: 5th Jan 1999
 35 // ===========================================     36 // =======================================================================
 36                                                    37 
 37 #ifndef HepRandom_h                                38 #ifndef HepRandom_h
 38 #define HepRandom_h 1                              39 #define HepRandom_h 1
 39                                                    40 
 40 #include "CLHEP/Random/RandomEngine.h"             41 #include "CLHEP/Random/RandomEngine.h"
 41                                                    42 
 42 namespace CLHEP {                                  43 namespace CLHEP {
 43                                                    44 
 44 /**                                                45 /**
 45  * @author <Gabriele.Cosmo@cern.ch>                46  * @author <Gabriele.Cosmo@cern.ch>
 46  * @ingroup random                                 47  * @ingroup random
 47  */                                                48  */
 48 class HepRandom {                                  49 class HepRandom {
 49                                                    50 
 50 public:                                            51 public:
 51                                                    52 
 52   HepRandom();                                     53   HepRandom();
 53   HepRandom(long seed);                            54   HepRandom(long seed);
 54   // Contructors with and without a seed using     55   // Contructors with and without a seed using the default engine
 55   // (MixMax).                                     56   // (MixMax).
 56                                                    57  
 57   HepRandom(HepRandomEngine & algorithm);          58   HepRandom(HepRandomEngine & algorithm);
 58   HepRandom(HepRandomEngine * algorithm);          59   HepRandom(HepRandomEngine * algorithm);
 59   // Constructor taking an alternative engine      60   // Constructor taking an alternative engine as argument. If a pointer is
 60   // given the corresponding object will be de     61   // given the corresponding object will be deleted by the HepRandom
 61   // destructor.                                   62   // destructor.
 62                                                    63   
 63   virtual ~HepRandom();                            64   virtual ~HepRandom();
 64   // Destructor                                    65   // Destructor
 65                                                    66   
 66   // implicitly allow compiler-generated copy      67   // implicitly allow compiler-generated copy functions 
 67                                                    68 
 68   double flat();                                   69   double flat();
 69   // Returns the flat value ( interval ]0...1[     70   // Returns the flat value ( interval ]0...1[ ).
 70                                                    71 
 71   void flatArray(const int size, double* vect)     72   void flatArray(const int size, double* vect);
 72   // Fills "vect" array of flat random values,     73   // Fills "vect" array of flat random values, given the size.
 73                                                    74 
 74   inline double flat (HepRandomEngine* theNewE     75   inline double flat (HepRandomEngine* theNewEngine);
 75   // Returns a flat value, given a defined Ran     76   // Returns a flat value, given a defined Random Engine.
 76                                                    77 
 77   inline void flatArray(HepRandomEngine* theNe     78   inline void flatArray(HepRandomEngine* theNewEngine, 
 78                         const int size, double     79                         const int size, double* vect);
 79   // Fills "vect" array of flat random values,     80   // Fills "vect" array of flat random values, given the size
 80   // and a defined Random Engine.                  81   // and a defined Random Engine.
 81                                                    82 
 82   virtual double operator()();                     83   virtual double operator()();
 83   // To get a flat random number using the ope     84   // To get a flat random number using the operator ().
 84                                                    85 
 85   virtual std::string name() const;                86   virtual std::string name() const;
 86   virtual HepRandomEngine & engine();              87   virtual HepRandomEngine & engine();
 87                                                    88     
 88                                                    89   
 89   virtual std::ostream & put ( std::ostream &      90   virtual std::ostream & put ( std::ostream & os ) const;
 90   virtual std::istream & get ( std::istream &      91   virtual std::istream & get ( std::istream & is );
 91   // Save and restore to/from streams              92   // Save and restore to/from streams
 92                                                    93 
 93   // -----------------------------------------     94   // --------------------------------------------------
 94   // Static member functions using the static      95   // Static member functions using the static generator
 95   // -----------------------------------------     96   // --------------------------------------------------
 96                                                    97 
 97   static void setTheSeed(long seed, int lxr=3) <<  98   static void setTheSeed(long seed, int lux=3);
 98   // (Re)Initializes the generator with a seed     99   // (Re)Initializes the generator with a seed.
 99                                                   100 
100   static long getTheSeed();                       101   static long getTheSeed();
101   // Gets the current seed of the current gene    102   // Gets the current seed of the current generator.
102                                                   103 
103   static void setTheSeeds(const long* seeds, i    104   static void setTheSeeds(const long* seeds, int aux=-1);
104   // (Re)Initializes the generator with a zero    105   // (Re)Initializes the generator with a zero terminated list of seeds.
105                                                   106 
106   static const long* getTheSeeds();               107   static const long* getTheSeeds();
107   // Gets the current array of seeds of the cu    108   // Gets the current array of seeds of the current generator.
108                                                   109 
109   static void getTheTableSeeds (long* seeds, i    110   static void getTheTableSeeds (long* seeds, int index);
110   // Gets the array of seeds in the static see    111   // Gets the array of seeds in the static seedTable at "index" position.
111                                                   112 
112   static HepRandom * getTheGenerator();           113   static HepRandom * getTheGenerator();
113   // Return the current static generator.         114   // Return the current static generator.
114                                                   115 
115   static void setTheEngine (HepRandomEngine* t    116   static void setTheEngine (HepRandomEngine* theNewEngine);
116   // To set the underlying algorithm object.      117   // To set the underlying algorithm object.
117                                                   118 
118   static HepRandomEngine * getTheEngine();        119   static HepRandomEngine * getTheEngine();
119   // Returns a pointer to the underlying algor    120   // Returns a pointer to the underlying algorithm object.
120                                                   121 
121   static void saveEngineStatus( const char fil    122   static void saveEngineStatus( const char filename[] = "Config.conf" );
122   // Saves to file the current status of the c    123   // Saves to file the current status of the current engine.
123                                                   124 
124   static void restoreEngineStatus( const char     125   static void restoreEngineStatus( const char filename[] = "Config.conf" );
125   // Restores a saved status (if any) for the     126   // Restores a saved status (if any) for the current engine.
126                                                   127 
127   static std::ostream& saveFullState ( std::os    128   static std::ostream& saveFullState ( std::ostream & os );
128   // Saves to stream the state of the engine a    129   // Saves to stream the state of the engine and cached data.
129                                                   130 
130   static std::istream& restoreFullState ( std:    131   static std::istream& restoreFullState ( std::istream & is );
131   // Restores from stream the state of the eng    132   // Restores from stream the state of the engine and cached data.
132                                                   133 
133   static std::ostream& saveDistState ( std::os    134   static std::ostream& saveDistState ( std::ostream & os ) {return os;}
134   // Saves to stream the state of the cached d    135   // Saves to stream the state of the cached data.
135                                                   136 
136   static std::istream& restoreDistState ( std:    137   static std::istream& restoreDistState ( std::istream & is ) {return is;}
137   // Restores from stream the state of the cac    138   // Restores from stream the state of the cached data.
138                                                   139 
139   static std::ostream& saveStaticRandomStates     140   static std::ostream& saveStaticRandomStates ( std::ostream & os );
140   // Saves to stream the engine and cached dat    141   // Saves to stream the engine and cached data for all distributions.
141                                                   142 
142   static std::istream& restoreStaticRandomStat    143   static std::istream& restoreStaticRandomStates ( std::istream & is );
143   // Restores from stream the engine and cache    144   // Restores from stream the engine and cached data for all distributions.
144                                                   145 
145   static void showEngineStatus();                 146   static void showEngineStatus();
146   // Dumps the current engine status on screen    147   // Dumps the current engine status on screen.
147                                                   148 
148   static int createInstance();                    149   static int createInstance();
149   // used to initialise the default engine        150   // used to initialise the default engine
150                                                   151 
151   static std::string distributionName() {retur    152   static std::string distributionName() {return "HepRandomEngine";}  
152   // Provides the name of this distribution cl    153   // Provides the name of this distribution class
153                                                   154        
154 protected:     // -------- Data members ------    155 protected:     // -------- Data members ---------
155                                                   156 
156   static const long seedTable[215][2];            157   static const long seedTable[215][2];
157   // Table of seeds                               158   // Table of seeds
158                                                   159 
159 };                                                160 };
160                                                   161 
161 std::ostream & operator<< (std::ostream & os,     162 std::ostream & operator<< (std::ostream & os, const HepRandom & dist);
162 std::istream & operator>> (std::istream & is,     163 std::istream & operator>> (std::istream & is, HepRandom & dist);
163                                                   164 
164 }  // namespace CLHEP                             165 }  // namespace CLHEP
165                                                   166 
166 #include "CLHEP/Random/Random.icc"                167 #include "CLHEP/Random/Random.icc"
167                                                   168 
168 #endif                                            169 #endif
169                                                   170