Random engine using drand48() and srand48() functions
from C standard library to implement the flat() basic
distribution and for setting seeds respectively.
DRand48Engine uses the seed48() function from
C standard library to retrieve the current internal status
of the generator, which is represented by 3 short values. Copies of an
object of this kind are not allowed. The engine state can be streamed
through ad-hoc defined stream operator<< and
operator>>.
For Windows/NT platforms (WIN32), the code for
drand48() has been extracted from the GNU C Library 2.0.1
and adapted for the native types.
Author
Gabriele Cosmo
See also
Engines:
HepRandomEngine,
DualRand
HepJamesRandom
Hurd160Engine
Hurd288Engine
MTwistEngine
RandEngine
RanecuEngine
RanluxEngine
Ranlux64Engine
RanshiEngine
TripleRand
Distributions:
HepRandom,
RandBinomial
RandBreitWigner
RandChiSquare
RandExponential
RandFlat
RandGamma
RandGauss
RandGeneral
RandPoisson
RandStudentT
Declaration
#include "CLHEP/Random/DRand48Engine.h"
class DRand48Engine : public HepRandomEngine
Public Member Functions
- Constructors
- DRand48Engine()
- DRand48Engine(long seed)
- DRand48Engine(HepInt rowIndex, HepInt colIndex)
- DRand48Engine(std::istream& is)
- Destructor
- virtual ~DRand48Engine()
- flat
- HepDouble flat()
- It returns a pseudo random number between 0 and 1,
according to the standard stdlib random function
drand48() but excluding the end points.
- flatArray
- void flatArray (const HepInt size, HepDouble* vect)
- Fills an array vect of specified size with flat random values.
- restoreStatus
- void restoreStatus(const char filename[] = "DRand48.conf")
- Reads from file DRand48.conf the last saved engine status
and restores it.
- saveStatus
- void saveStatus(const char filename[] = "DRand48.conf") const
- Saves on file DRand48.conf the current engine status.
- setSeed
- void setSeed(long seed, HepInt dum=0)
- Sets the state of the algorithm according to seed.
- setSeeds
- void setSeeds(const long * seeds, HepInt dum=0)
- Sets the state of the algorithm according to the zero terminated
array of seeds. Only the first seed is used.
- showStatus
- void showStatus() const
- Dumps the engine status on the screen.
Non-Member Functions
- <<
- std::ostream & operator<< (std::ostream & os,
const DRand48Engine & e)
- Output to a stream.
- >>
- std::istream & operator>> (std::istream & is,
DRand48Engine & e)
- Input from a stream.
Example
CLHEP/test/testRandom.cc
04 May 1999
EVC