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

RandomObjects/CLHEP/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"
49
50namespace CLHEP {
51
57
58public:
59
60 DRand48Engine(std::istream& is);
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
106private:
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
117using namespace CLHEP;
118#endif
119
120#endif
virtual std::istream & getState(std::istream &is)
void showStatus() const
virtual std::ostream & put(std::ostream &os) const
virtual ~DRand48Engine()
bool getState(const std::vector< unsigned long > &v)
void setSeed(long seed, int dum=0)
void setSeeds(const long *seeds, int dum=0)
bool get(const std::vector< unsigned long > &v)
void saveStatus(const char filename[]="DRand48.conf") const
DRand48Engine(int rowIndex, int colIndex)
std::vector< unsigned long > put() const
DRand48Engine(std::istream &is)
static const unsigned int VECTOR_STATE_SIZE
static std::string beginTag()
virtual std::istream & get(std::istream &is)
DRand48Engine(long seed)
std::string name() const
void restoreStatus(const char filename[]="DRand48.conf")
void flatArray(const int size, double *vect)