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

DRand48Engine.h

Go to the documentation of this file.
00001 // $Id: DRand48Engine.h,v 1.5 2010/06/16 17:24:53 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                        --- DRand48Engine ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 // This file is part of Geant4 (simulation toolkit for HEP).
00010 //
00011 // Random engine using drand48() and srand48() functions from C standard
00012 // library to implement the flat() basic distribution and for setting
00013 // seeds.
00014 // For Windows/NT platforms (WIN32), the code for drand48 has been
00015 // extracted from the GNU C Library 2.0.1 and adapted for the native
00016 // types.
00017 // Copy constructor and operator= are private for objects of this class.
00018 
00019 // =======================================================================
00020 // G.Cosmo        - Created: 5th September 1995
00021 //                - Minor corrections: 31st October 1996
00022 //                - Added methods for engine status: 19th November 1996
00023 //                - Added srand48(), seed48(), drand48() implementations
00024 //                  for Windows/NT: 6th March 1997
00025 //                - setSeed(), setSeeds() now have default dummy argument
00026 //                  set to zero: 11th July 1997
00027 // E.Tcherniaev   - Porting on KCC compiler: 2nd Feb 1998
00028 // G.Cosmo        - Private copy constructor and operator=: 26th Feb 1998
00029 // J.Marraffino   - Added stream operators and related constructor.
00030 //                  Added automatic seed selection from seed table and
00031 //                  engine counter: 16th Feb 1998
00032 // E.Tcherniaev   - Removed #ifdef for prototypes for drand48(), srand48()
00033 //                  and seed48();
00034 //                - More accurate code for drand48() on NT base on
00035 //                  a code extracted from GNU C Library 2.1.3: 8th Nov 2000
00036 // E.Tcherniaev   - prototypes for drand48(), srand48() and seed48() have
00037 //                  been moved to DRand48Engine.cc: 21 Feb 2002
00038 // Mark Fischler  - methods for distrib. instance save/restore 12/8/04    
00039 // Mark Fischler  - methods for anonymous save/restore 12/27/04 
00040 // Mark Fischler  - methods for vector save/restore 3/7/05    
00041 // =======================================================================
00042 
00043 #ifndef DRand48Engine_h
00044 #define DRand48Engine_h 1
00045 
00046 #include "CLHEP/Random/defs.h"
00047 #include "CLHEP/Random/RandomEngine.h"
00048 #include "CLHEP/Utility/noncopyable.h"
00049 
00050 namespace CLHEP {
00051 
00056 class DRand48Engine : public HepRandomEngine, public noncopyable {
00057 
00058 public:
00059 
00060   DRand48Engine(std::istream& is);
00061   DRand48Engine();
00062   DRand48Engine(long seed);
00063   DRand48Engine(int rowIndex, int colIndex);
00064   virtual ~DRand48Engine();
00065   // Constructors and destructor
00066 
00067   double flat();
00068   // It returns a pseudo random number between 0 and 1,
00069   // according to the standard stdlib random function drand48()
00070   // but excluding the end points.
00071 
00072   void flatArray (const int size, double* vect);
00073   // Fills the array "vect" of specified size with flat random values.
00074 
00075   void setSeed(long seed, int dum=0);
00076   // Sets the state of the algorithm according to seed.
00077 
00078   void setSeeds(const long * seeds, int dum=0);
00079   // Sets the state of the algorithm according to the zero terminated
00080   // array of seeds. Only the first seed is used.
00081 
00082   void saveStatus( const char filename[] = "DRand48.conf" ) const;
00083   // Saves on file DRand48.conf the current engine status.
00084 
00085   void restoreStatus( const char filename[] = "DRand48.conf" );
00086   // Reads from file DRand48.conf the last saved engine status
00087   // and restores it.
00088 
00089   void showStatus() const;
00090   // Dumps the engine status on the screen.
00091 
00092   virtual std::ostream & put (std::ostream & os) const;
00093   virtual std::istream & get (std::istream & is);
00094   static  std::string beginTag ( );
00095   virtual std::istream & getState ( std::istream & is );
00096 
00097   std::string name() const;
00098   static std::string engineName() {return "DRand48Engine";}
00099 
00100   std::vector<unsigned long> put () const;
00101   bool get (const std::vector<unsigned long> & v);
00102   bool getState (const std::vector<unsigned long> & v);
00103 
00104   static const unsigned int VECTOR_STATE_SIZE = 4;
00105   
00106 private:
00107 
00108   static int  numEngines;
00109   static int  maxIndex;
00110 
00111 };
00112 
00113 }  // namespace CLHEP
00114 
00115 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00116 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00117 using namespace CLHEP;
00118 #endif
00119 
00120 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7