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

Random/Random/DRand48Engine.h
Go to the documentation of this file.
1 // $Id: DRand48Engine.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- DRand48Engine ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // Random engine using drand48() and srand48() functions from C standard
12 // library to implement the flat() basic distribution and for setting
13 // seeds.
14 // For Windows/NT platforms (WIN32), the code for drand48 has been
15 // extracted from the GNU C Library 2.0.1 and adapted for the native
16 // types.
17 // Copy constructor and operator= are private for objects of this class.
18 
19 // =======================================================================
20 // G.Cosmo - Created: 5th September 1995
21 // - Minor corrections: 31st October 1996
22 // - Added methods for engine status: 19th November 1996
23 // - Added srand48(), seed48(), drand48() implementations
24 // for Windows/NT: 6th March 1997
25 // - setSeed(), setSeeds() now have default dummy argument
26 // set to zero: 11th July 1997
27 // E.Tcherniaev - Porting on KCC compiler: 2nd Feb 1998
28 // G.Cosmo - Private copy constructor and operator=: 26th Feb 1998
29 // J.Marraffino - Added stream operators and related constructor.
30 // Added automatic seed selection from seed table and
31 // engine counter: 16th Feb 1998
32 // E.Tcherniaev - Removed #ifdef for prototypes for drand48(), srand48()
33 // and seed48();
34 // - More accurate code for drand48() on NT base on
35 // a code extracted from GNU C Library 2.1.3: 8th Nov 2000
36 // E.Tcherniaev - prototypes for drand48(), srand48() and seed48() have
37 // been moved to DRand48Engine.cc: 21 Feb 2002
38 // Mark Fischler - methods for distrib. instance save/restore 12/8/04
39 // Mark Fischler - methods for anonymous save/restore 12/27/04
40 // Mark Fischler - methods for vector save/restore 3/7/05
41 // =======================================================================
42 
43 #ifndef DRand48Engine_h
44 #define DRand48Engine_h 1
45 
46 #include "CLHEP/Random/defs.h"
47 #include "CLHEP/Random/RandomEngine.h"
48 #include "CLHEP/Utility/noncopyable.h"
49 
50 namespace CLHEP {
51 
56 class DRand48Engine : public HepRandomEngine, public noncopyable {
57 
58 public:
59 
60  DRand48Engine(std::istream& is);
61  DRand48Engine();
62  DRand48Engine(long seed);
63  DRand48Engine(int rowIndex, int colIndex);
64  virtual ~DRand48Engine();
65  // Constructors and destructor
66 
67  double flat();
68  // It returns a pseudo random number between 0 and 1,
69  // according to the standard stdlib random function drand48()
70  // but 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 dum=0);
76  // Sets the state of the algorithm according to seed.
77 
78  void setSeeds(const long * seeds, int dum=0);
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[] = "DRand48.conf" ) const;
83  // Saves on file DRand48.conf the current engine status.
84 
85  void restoreStatus( const char filename[] = "DRand48.conf" );
86  // Reads from file DRand48.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  virtual std::ostream & put (std::ostream & os) const;
93  virtual std::istream & get (std::istream & is);
94  static std::string beginTag ( );
95  virtual std::istream & getState ( std::istream & is );
96 
97  std::string name() const;
98  static std::string engineName() {return "DRand48Engine";}
99 
100  std::vector<unsigned long> put () const;
101  bool get (const std::vector<unsigned long> & v);
102  bool getState (const std::vector<unsigned long> & v);
103 
104  static const unsigned int VECTOR_STATE_SIZE = 4;
105 
106 private:
107 
108  static int numEngines;
109  static int maxIndex;
110 
111 };
112 
113 } // namespace CLHEP
114 
115 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
116 // backwards compatibility will be enabled ONLY in CLHEP 1.9
117 using namespace CLHEP;
118 #endif
119 
120 #endif
CLHEP::DRand48Engine::put
std::vector< unsigned long > put() const
Definition: DRand48Engine.cc:247
CLHEP::DRand48Engine::showStatus
void showStatus() const
Definition: DRand48Engine.cc:188
CLHEP::DRand48Engine::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/DRand48Engine.h:104
CLHEP::DRand48Engine::restoreStatus
void restoreStatus(const char filename[]="DRand48.conf")
Definition: DRand48Engine.cc:149
CLHEP::DRand48Engine::setSeed
void setSeed(long seed, int dum=0)
Definition: DRand48Engine.cc:101
CLHEP::DRand48Engine::setSeeds
void setSeeds(const long *seeds, int dum=0)
Definition: DRand48Engine.cc:107
CLHEP::DRand48Engine::engineName
static std::string engineName()
Definition: Random/Random/DRand48Engine.h:98
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
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
CLHEP::DRand48Engine::getState
virtual std::istream & getState(std::istream &is)
Definition: DRand48Engine.cc:282
CLHEP::DRand48Engine::~DRand48Engine
virtual ~DRand48Engine()
Definition: DRand48Engine.cc:99
CLHEP::DRand48Engine::name
std::string name() const
Definition: DRand48Engine.cc:49
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::DRand48Engine::get
virtual std::istream & get(std::istream &is)
Definition: DRand48Engine.cc:260
CLHEP::DRand48Engine::beginTag
static std::string beginTag()
Definition: DRand48Engine.cc:278
CLHEP::DRand48Engine::flatArray
void flatArray(const int size, double *vect)
Definition: DRand48Engine.cc:213
CLHEP::DRand48Engine::saveStatus
void saveStatus(const char filename[]="DRand48.conf") const
Definition: DRand48Engine.cc:113
CLHEP::DRand48Engine::DRand48Engine
DRand48Engine()
Definition: DRand48Engine.cc:61
CLHEP::DRand48Engine::flat
double flat()
Definition: DRand48Engine.cc:204