CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandomObjects/CLHEP/Random/RanluxEngine.h
Go to the documentation of this file.
1 // $Id: RanluxEngine.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RanluxEngine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // The algorithm for this random engine has been taken from the original
12 // implementation in FORTRAN by Fred James as part of the MATHLIB HEP
13 // library.
14 // The initialisation is carried out using a Multiplicative Congruential
15 // generator using formula constants of L'Ecuyer as described in "F.James,
16 // Comp. Phys. Comm. 60 (1990) 329-344".
17 
18 // =======================================================================
19 // Adeyemi Adesanya - Created: 6th November 1995
20 // Gabriele Cosmo - Adapted & Revised: 22nd November 1995
21 // Adeyemi Adesanya - Added setSeeds() method: 2nd February 1996
22 // Gabriele Cosmo - Added flatArray() method: 8th February 1996
23 // - Added methods for engine status: 19th November 1996
24 // - Added default luxury value for setSeed()
25 // and setSeeds(): 21st July 1997
26 // J.Marraffino - Added stream operators and related constructor.
27 // Added automatic seed selection from seed table and
28 // engine counter: 14th Feb 1998
29 // Ken Smith - Added conversion operators: 6th Aug 1998
30 // Mark Fischler Methods put, get for instance save/restore 12/8/04
31 // Mark Fischler methods for anonymous save/restore 12/27/04
32 // =======================================================================
33 
34 #ifndef RanluxEngine_h
35 #define RanluxEngine_h 1
36 
37 #include "CLHEP/Random/defs.h"
38 #include "CLHEP/Random/RandomEngine.h"
39 
40 namespace CLHEP {
41 
46 class RanluxEngine : public HepRandomEngine {
47 
48 public:
49 
50  RanluxEngine( std::istream& is );
51  RanluxEngine();
52  RanluxEngine( long seed, int lux = 3 );
53  RanluxEngine( int rowIndex, int colIndex, int lux );
54  virtual ~RanluxEngine();
55  // Constructors and destructor
56 
57 // Luxury level is set in the same way as the original FORTRAN routine.
58 // level 0 (p=24): equivalent to the original RCARRY of Marsaglia
59 // and Zaman, very long period, but fails many tests.
60 // level 1 (p=48): considerable improvement in quality over level 0,
61 // now passes the gap test, but still fails spectral test.
62 // level 2 (p=97): passes all known tests, but theoretically still
63 // defective.
64 // level 3 (p=223): DEFAULT VALUE. Any theoretically possible
65 // correlations have very small chance of being observed.
66 // level 4 (p=389): highest possible luxury, all 24 bits chaotic.
67 
68  double flat();
69  // It returns a pseudo random number between 0 and 1,
70  // excluding the end points.
71 
72  void flatArray (const int size, double* vect);
73  // Fills the array "vect" of specified size with flat random values.
74 
75  void setSeed(long seed, int lux=3);
76  // Sets the state of the algorithm according to seed.
77 
78  void setSeeds(const long * seeds, int lux=3);
79  // Sets the state of the algorithm according to the zero terminated
80  // array of seeds. Only the first seed is used.
81 
82  void saveStatus( const char filename[] = "Ranlux.conf" ) const;
83  // Saves on file Ranlux.conf the current engine status.
84 
85  void restoreStatus( const char filename[] = "Ranlux.conf" );
86  // Reads from file Ranlux.conf the last saved engine status
87  // and restores it.
88 
89  void showStatus() const;
90  // Dumps the engine status on the screen.
91 
92  int getLuxury() const { return luxury; }
93  // Gets the luxury level.
94 
95  operator unsigned int(); // 32-bit flat, but slower than double or float
96 
97  virtual std::ostream & put (std::ostream & os) const;
98  virtual std::istream & get (std::istream & is);
99  static std::string beginTag ( );
100  virtual std::istream & getState ( std::istream & is );
101 
102  std::string name() const;
103  static std::string engineName() {return "RanluxEngine";}
104 
105  std::vector<unsigned long> put () const;
106  bool get (const std::vector<unsigned long> & v);
107  bool getState (const std::vector<unsigned long> & v);
108 
109  static const unsigned int VECTOR_STATE_SIZE = 31;
110 
111 private:
112 
113  int nskip, luxury;
114  float float_seed_table[24];
115  int i_lag,j_lag;
116  float carry;
117  int count24;
118  static const int int_modulus = 0x1000000;
119  static int numEngines;
120  static int maxIndex;
121 };
122 
123 } // namespace CLHEP
124 
125 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
126 // backwards compatibility will be enabled ONLY in CLHEP 1.9
127 using namespace CLHEP;
128 #endif
129 
130 #endif
CLHEP::RanluxEngine::showStatus
void showStatus() const
Definition: RanluxEngine.cc:323
CLHEP::RanluxEngine::RanluxEngine
RanluxEngine()
Definition: RanluxEngine.cc:79
CLHEP::RanluxEngine::put
std::vector< unsigned long > put() const
Definition: RanluxEngine.cc:506
CLHEP::RanluxEngine::getState
virtual std::istream & getState(std::istream &is)
Definition: RanluxEngine.cc:560
CLHEP::RanluxEngine::engineName
static std::string engineName()
Definition: RandomObjects/CLHEP/Random/RanluxEngine.h:103
CLHEP::RanluxEngine::~RanluxEngine
virtual ~RanluxEngine()
Definition: RanluxEngine.cc:127
CLHEP::RanluxEngine::restoreStatus
void restoreStatus(const char filename[]="Ranlux.conf")
Definition: RanluxEngine.cc:284
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::RanluxEngine::get
virtual std::istream & get(std::istream &is)
Definition: RanluxEngine.cc:538
CLHEP::RanluxEngine::setSeeds
void setSeeds(const long *seeds, int lux=3)
Definition: RanluxEngine.cc:185
CLHEP::RanluxEngine::getLuxury
int getLuxury() const
Definition: RandomObjects/CLHEP/Random/RanluxEngine.h:92
CLHEP::RanluxEngine::flat
double flat()
Definition: RanluxEngine.cc:338
size
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
CLHEP
Definition: ClhepVersion.h:13
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
seeds
Technical Maintenance Note for CLHEP Random Consequences of seeding JamesRandom with positive seed values greater than In the source code JamesRandom The usual way of seeding a generator is via the default which makes use of the table of seeds(with some trickery to ensure that the values won 't repeat after the table rows are exhausted). The trickery preserves the fact that sees are never negative(because the table values are never negative
CLHEP::RanluxEngine::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/RanluxEngine.h:109
CLHEP::RanluxEngine::flatArray
void flatArray(const int size, double *vect)
Definition: RanluxEngine.cc:420
CLHEP::RanluxEngine::setSeed
void setSeed(long seed, int lux=3)
Definition: RanluxEngine.cc:129
CLHEP::RanluxEngine::saveStatus
void saveStatus(const char filename[]="Ranlux.conf") const
Definition: RanluxEngine.cc:251
CLHEP::RanluxEngine::name
std::string name() const
Definition: RanluxEngine.cc:57
CLHEP::RanluxEngine::beginTag
static std::string beginTag()
Definition: RanluxEngine.cc:556