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


  1 /*                                                  1 
  2 Code adapted from:                                
  3 http://www.jstatsoft.org/v05/i08/                 
  4                                                   
  5                                                   
  6 Original disclaimer:                              
  7                                                   
  8 The ziggurat method for RNOR and REXP             
  9 Combine the code below with the main program i    
 10 normal or exponential variates.   Then use of     
 11 will provide a standard normal variate with me    
 12 while use of REXP in any expression will provi    
 13 with density exp(-x),x>0.                         
 14 Before using RNOR or REXP in your main, insert    
 15 zigset(86947731 );                                
 16 with your own choice of seed value>0, rather t    
 17 (If you do not invoke zigset(...) you will get    
 18 For details of the method, see Marsaglia and T    
 19 for generating random variables", Journ. Stati    
 20                                                   
 21 */                                                
 22                                                   
 23 #ifndef RandExpZiggurat_h                         
 24 #define RandExpZiggurat_h 1                       
 25                                                   
 26 #include "CLHEP/Random/Random.h"                  
 27 #include "CLHEP/Utility/memory.h"                 
 28 #include "CLHEP/Utility/thread_local.h"           
 29                                                   
 30 namespace CLHEP {                                 
 31                                                   
 32 /**                                               
 33  * @author ATLAS                                  
 34  * @ingroup random                                
 35  */                                               
 36 class RandExpZiggurat : public HepRandom {        
 37                                                   
 38 public:                                           
 39                                                   
 40   inline RandExpZiggurat ( HepRandomEngine& an    
 41   inline RandExpZiggurat ( HepRandomEngine* an    
 42   // These constructors should be used to inst    
 43   // distribution object defining a local engi    
 44   // The static generator will be skipped usin    
 45   // defined below.                               
 46   // If the engine is passed by pointer the co    
 47   // will be deleted by the RandExpZiggurat de    
 48   // If the engine is passed by reference the     
 49   // will not be deleted by the RandExpZiggura    
 50                                                   
 51   virtual ~RandExpZiggurat();                     
 52   // Destructor                                   
 53                                                   
 54   // Static methods to shoot random values usi    
 55                                                   
 56   static float shoot() {return shoot(HepRandom    
 57   static float shoot( float mean ) {return sho    
 58                                                   
 59   /* ENGINE IS INTRINSIC FLOAT                    
 60   static double shoot() {return shoot(HepRando    
 61   static double shoot( double mean ) {return s    
 62   */                                              
 63                                                   
 64   static void shootArray ( const int size, flo    
 65   static void shootArray ( const int size, dou    
 66                                                   
 67   //  Static methods to shoot random values us    
 68   //  by-passing the static generator.            
 69                                                   
 70   static inline float shoot( HepRandomEngine*     
 71   static inline float shoot( HepRandomEngine*     
 72                                                   
 73   /* ENGINE IS INTRINSIC FLOAT                    
 74   static inline double shoot( HepRandomEngine*    
 75                                                   
 76   static inline double shoot( HepRandomEngine*    
 77   */                                              
 78                                                   
 79   static void shootArray ( HepRandomEngine* an    
 80   static void shootArray ( HepRandomEngine* an    
 81                                                   
 82   //  Methods using the localEngine to shoot r    
 83   //  the static generator.                       
 84                                                   
 85   inline float fire() {return fire(float(defau    
 86   inline float fire( float mean ) {return zigg    
 87                                                   
 88   /* ENGINE IS INTRINSIC FLOAT                    
 89   inline double fire() {return fire(defaultMea    
 90   inline double fire( double mean ) {return zi    
 91   */                                              
 92                                                   
 93   void fireArray ( const int size, float* vect    
 94   void fireArray ( const int size, double* vec    
 95   void fireArray ( const int size, float* vect    
 96   void fireArray ( const int size, double* vec    
 97                                                   
 98   virtual double operator()();                    
 99   inline float operator()( float mean ) {retur    
100                                                   
101   // Save and restore to/from streams             
102                                                   
103   std::ostream & put ( std::ostream & os ) con    
104   std::istream & get ( std::istream & is );       
105                                                   
106   std::string name() const;                       
107   HepRandomEngine & engine();                     
108                                                   
109   static std::string distributionName() {retur    
110   // Provides the name of this distribution cl    
111                                                   
112   static bool ziggurat_init();                    
113 protected:                                        
114   //////////////////////////                      
115   // Ziggurat Original code:                      
116   //////////////////////////                      
117   //static unsigned long jz,jsr=123456789;        
118   //                                              
119   //#define SHR3 (jz=jsr, jsr^=(jsr<<13), jsr^    
120   //#define UNI (.5 + (signed) SHR3*.2328306e-    
121   //#define IUNI SHR3                             
122   //                                              
123   //static long hz;                               
124   //static unsigned long iz, kn[128], ke[256];    
125   //static float wn[128],fn[128], we[256],fe[2    
126   //                                              
127   //#define RNOR (hz=SHR3, iz=hz&127, (fabs(hz    
128   //#define REXP (jz=SHR3, iz=jz&255, (    jz     
129                                                   
130   static CLHEP_THREAD_LOCAL unsigned long kn[1    
131   static CLHEP_THREAD_LOCAL float wn[128],fn[1    
132                                                   
133   static CLHEP_THREAD_LOCAL bool ziggurat_is_i    
134                                                   
135   static inline unsigned long ziggurat_SHR3(He    
136   static inline float ziggurat_UNI(HepRandomEn    
137   static inline float ziggurat_REXP(HepRandomE    
138     if(!ziggurat_is_init) ziggurat_init();        
139     unsigned long jz=ziggurat_SHR3(anEngine);     
140     unsigned long iz=jz&255;                      
141     return (jz<ke[iz]) ? jz*we[iz] : ziggurat_    
142   }                                               
143   static float ziggurat_efix(unsigned long jz,    
144                                                   
145 private:                                          
146                                                   
147   // Private copy constructor. Defining it her    
148   RandExpZiggurat(const RandExpZiggurat& d);      
149                                                   
150   std::shared_ptr<HepRandomEngine> localEngine    
151   double defaultMean;                             
152 };                                                
153                                                   
154 }  // namespace CLHEP                             
155                                                   
156 namespace CLHEP {                                 
157                                                   
158 inline RandExpZiggurat::RandExpZiggurat(HepRan    
159 {                                                 
160 }                                                 
161                                                   
162 inline RandExpZiggurat::RandExpZiggurat(HepRan    
163 {                                                 
164 }                                                 
165                                                   
166 }  // namespace CLHEP                             
167                                                   
168 #endif                                            
169