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

Matrix/CLHEP/Random/JamesRandom.h
Go to the documentation of this file.
1 // $Id: JamesRandom.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- HepJamesRandom ---
7 // class header file
8 // -----------------------------------------------------------------------
9 // This file is part of Geant4 (simulation toolkit for HEP).
10 //
11 // HepJamesRandom implements the algorithm by Marsaglia-Zaman RANMAR
12 // described in "F.James, Comp. Phys. Comm. 60 (1990) 329" and implemented
13 // in FORTRAN77 as part of the MATHLIB HEP library for pseudo-random
14 // numbers generation.
15 // This is the default random engine invoked by each distribution unless
16 // the user sets a different one.
17 
18 // =======================================================================
19 // Gabriele Cosmo - Created: 5th September 1995
20 // - Minor corrections: 31st October 1996
21 // - Added methods for engine status: 19th November 1996
22 // - setSeed(), setSeeds() now have default dummy argument
23 // set to zero: 11th July 1997
24 // J.Marraffino - Added stream operators and related constructor.
25 // Added automatic seed selection from seed table and
26 // engine counter: 16th Feb 1998
27 // Ken Smith - Added conversion operators: 6th Aug 1998
28 // V. Innocente - changed pointers to indices 3 may 2000
29 // Mark Fischler - Methods for distrib. instance save/restore 12/8/04
30 // Mark Fischler methods for anonymous save/restore 12/27/04
31 // =======================================================================
32 
33 #ifndef HepJamesRandom_h
34 #define HepJamesRandom_h 1
35 
36 #include "CLHEP/Random/defs.h"
37 #include "CLHEP/Random/RandomEngine.h"
38 
39 namespace CLHEP {
40 
46 
47 public:
48 
49  HepJamesRandom(std::istream& is);
51  HepJamesRandom(long seed);
52  HepJamesRandom(int rowIndex, int colIndex);
53  virtual ~HepJamesRandom();
54  // Constructor and destructor.
55 
56  double flat();
57  // Returns a pseudo random number between 0 and 1
58  // (excluding the end points)
59 
60  void flatArray (const int size, double* vect);
61  // Fills the array "vect" of specified size with flat random values.
62 
63  void setSeed(long seed, int dum=0);
64  // Sets the state of the algorithm according to seed.
65 
66  void setSeeds(const long * seeds, int dum=0);
67  // Sets the state of the algorithm according to the zero terminated
68  // array of seeds. Only the first seed is used.
69 
70  void saveStatus( const char filename[] = "JamesRand.conf" ) const;
71  // Saves on file JamesRand.conf the current engine status.
72 
73  void restoreStatus( const char filename[] = "JamesRand.conf" );
74  // Reads from file JamesRand.conf the last saved engine status
75  // and restores it.
76 
77  void showStatus() const;
78  // Dumps the engine status on the screen.
79 
80  operator unsigned int();
81  // 32-bit flat, but slower than double or float.
82 
83  virtual std::ostream & put (std::ostream & os) const;
84  virtual std::istream & get (std::istream & is);
85  static std::string beginTag ( );
86  virtual std::istream & getState ( std::istream & is );
87 
88  std::string name() const;
89  static std::string engineName() {return "HepJamesRandom";}
90 
91  std::vector<unsigned long> put () const;
92  bool get (const std::vector<unsigned long> & v);
93  bool getState (const std::vector<unsigned long> & v);
94 
95  static const unsigned int VECTOR_STATE_SIZE = 202;
96 
97 private:
98 
99  // Members defining the current status of the generator.
100  double u[97];
101  double c, cd, cm;
102  int i97, j97;
103  static int numEngines;
104  static int maxIndex;
105 };
106 
107 } // namespace CLHEP
108 
109 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
110 // backwards compatibility will be enabled ONLY in CLHEP 1.9
111 using namespace CLHEP;
112 #endif
113 
114 #endif
CLHEP::HepJamesRandom::flat
double flat()
Definition: JamesRandom.cc:259
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
CLHEP::HepJamesRandom::~HepJamesRandom
virtual ~HepJamesRandom()
Definition: JamesRandom.cc:107
CLHEP::HepJamesRandom::put
std::vector< unsigned long > put() const
Definition: JamesRandom.cc:326
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::HepJamesRandom::setSeeds
void setSeeds(const long *seeds, int dum=0)
Definition: JamesRandom.cc:253
CLHEP::HepJamesRandom
Definition: Matrix/CLHEP/Random/JamesRandom.h:45
CLHEP::HepJamesRandom::flatArray
void flatArray(const int size, double *vect)
Definition: JamesRandom.cc:284
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::HepJamesRandom::getState
virtual std::istream & getState(std::istream &is)
Definition: JamesRandom.cc:366
CLHEP::HepJamesRandom::HepJamesRandom
HepJamesRandom()
Definition: JamesRandom.cc:69
CLHEP::HepJamesRandom::name
std::string name() const
Definition: JamesRandom.cc:54
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::HepJamesRandom::restoreStatus
void restoreStatus(const char filename[]="JamesRand.conf")
Definition: JamesRandom.cc:143
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::HepJamesRandom::get
virtual std::istream & get(std::istream &is)
Definition: JamesRandom.cc:345
CLHEP::HepJamesRandom::saveStatus
void saveStatus(const char filename[]="JamesRand.conf") const
Definition: JamesRandom.cc:109
CLHEP::HepJamesRandom::setSeed
void setSeed(long seed, int dum=0)
Definition: JamesRandom.cc:201
CLHEP::HepJamesRandom::beginTag
static std::string beginTag()
Definition: JamesRandom.cc:362
CLHEP::HepJamesRandom::VECTOR_STATE_SIZE
static const unsigned int VECTOR_STATE_SIZE
Definition: Matrix/CLHEP/Random/JamesRandom.h:95
CLHEP::HepJamesRandom::showStatus
void showStatus() const
Definition: JamesRandom.cc:185
CLHEP::HepJamesRandom::engineName
static std::string engineName()
Definition: Matrix/CLHEP/Random/JamesRandom.h:89