CLHEP  2.4.7.2
C++ Class Library for High Energy Physics
RandomVector.icc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // -----------------------------------------------------------------------
4 // HEP Random
5 // --- HepRandomVector ---
6 // inlined functions implementation file
7 // -----------------------------------------------------------------------
8 // =======================================================================
9 // Mark Fischler - Created: 19th October 1998
10 // =======================================================================
11 
12 namespace CLHEP {
13 
14 inline void HepRandomVector::setSeed(long seed, int lux) {
15  theEngine->setSeed(seed,lux);
16 }
17 
18 inline void HepRandomVector::setSeeds(const long* seeds, int aux) {
19  theEngine->setSeeds(seeds,aux);
20 }
21 
22 inline long HepRandomVector::getSeed() const {
23  return theEngine->getSeed();
24 }
25 
26 inline const long* HepRandomVector::getSeeds() const {
27  return theEngine->getSeeds();
28 }
29 
30 inline void HepRandomVector::saveStatus( const char filename[] ) const {
31  theEngine->saveStatus( filename );
32 }
33 
34 inline void HepRandomVector::restoreStatus( const char filename[] ) {
35  theEngine->restoreStatus( filename );
36 }
37 
38 inline void HepRandomVector::showStatus() const {
39  theEngine->showStatus();
40 }
41 
42 // In analogy to the HepRandom class, we inline the following, even though now
43 // they contain a loop to fill a vector and are thus more complicated.
44 
45 inline HepVector HepRandomVector::flat() {
46  HepVector v;
47  int i;
48  for ( i = 0; i < v.num_row(); i++ ) {
49  v[i] = theEngine->flat();
50  }
51  // Instead of this loop, the engine's flatArray routine could be
52  // used if there were a guarantee that the memory for the HepVector
53  // is merely its members in order. But there is no such guarantee.
54  return v;
55 }
56 
57 inline void HepRandomVector::flatArray(const int size, HepVector* vect) {
58  int n;
59  int i;
60  for ( n = 0; n < size; n++ ) {
61  for ( i = 0; i < vect[n].num_row(); i++ ) {
62  vect[n][i] = theEngine->flat();
63  // Here, the engine's flatArray routine is not good
64  // to use because each element of vect is std:vector
65  }
66  }
67 }
68 
69 inline HepVector HepRandomVector::flat(HepRandomEngine* theNewEngine)
70 {
71  HepVector v;
72  int i;
73  for ( i = 0; i < v.num_row(); i++ ) {
74  v[i] = theNewEngine->flat();
75  }
76  return v;
77 }
78 
79 inline void HepRandomVector::flatArray(HepRandomEngine* theNewEngine,
80  const int size, HepVector* vect)
81 {
82  int n;
83  int i;
84  for ( n = 0; n < size; n++ ) {
85  for ( i = 0; i < vect[n].num_row(); i++ ) {
86  vect[n][i] = theNewEngine->flat();
87  }
88  }
89 }
90 
91 } // namespace CLHEP