/usr/include/CLHEP/Random/RandFlat.icc is in libclhep-dev 2.1.4.1+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | // $Id: RandFlat.icc,v 1.3 2010/06/16 17:24:53 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
// HEP Random
// --- RandFlat ---
// inlined functions implementation file
// -----------------------------------------------------------------------
// This file is part of Geant4 (simulation toolkit for HEP).
// =======================================================================
// Gabriele Cosmo - Created: 5th September 1995
// Peter Urban - ShootBit() and related stuff added: 5th Sep 1996
// Gabriele Cosmo - Additional methods to fill arrays specifying
// boundaries: 24th Jul 1997
// - Fixed bug in shootInt(m,n): 25th Sep 1997
// J.Marraffino - Added default arguments as attributes: 16th Feb 1998
// M.Fischler - Corrected initialization of deleteEngine which should
// be true for all constructors taking HepRandomEngine*.
// =======================================================================
namespace CLHEP {
inline RandFlat::RandFlat(HepRandomEngine & anEngine)
: HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
defaultWidth(1.0), defaultA(0.0), defaultB(1.0) {}
inline RandFlat::RandFlat(HepRandomEngine & anEngine, double width )
: HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
defaultWidth(width), defaultA(0.0), defaultB(width) {}
inline RandFlat::RandFlat(HepRandomEngine & anEngine, double a,
double b )
: HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
defaultWidth(b-a), defaultA(a), defaultB(b) {}
inline RandFlat::RandFlat(HepRandomEngine * anEngine)
: HepRandom(), firstUnusedBit(0), localEngine(anEngine),
defaultWidth(1.0), defaultA(0.0), defaultB(1.0) {}
inline RandFlat::RandFlat(HepRandomEngine * anEngine, double width )
: HepRandom(), firstUnusedBit(0), localEngine(anEngine),
defaultWidth(width), defaultA(0.0), defaultB(width) {}
inline RandFlat::RandFlat(HepRandomEngine * anEngine, double a,
double b )
: HepRandom(), firstUnusedBit(0), localEngine(anEngine),
defaultWidth(b-a), defaultA(a), defaultB(b) {}
inline double RandFlat::shoot(double a, double b) {
return (b-a)* shoot() + a;
}
inline double RandFlat::shoot(double width) {
return width * shoot();
}
inline long RandFlat::shootInt(long n) {
return long(shoot()*double(n));
}
inline long RandFlat::shootInt(long a1, long n) {
return long(shoot()*double(n-a1)) + a1;
}
inline void RandFlat::shootBits() {
const double factor= 2.0*MSB; // this should fit into a double!
staticFirstUnusedBit= MSB;
staticRandomInt= (unsigned long)(factor*shoot());
}
inline int RandFlat::shootBit() {
if (staticFirstUnusedBit==0)
shootBits();
unsigned long temp= staticFirstUnusedBit&staticRandomInt;
staticFirstUnusedBit>>= 1;
return temp!=0;
}
//---------------------
inline double RandFlat::shoot(HepRandomEngine* anEngine) {
return anEngine->flat();
}
inline double RandFlat::shoot(HepRandomEngine* anEngine,
double a, double b) {
return (b-a)* anEngine->flat() + a;
}
inline double RandFlat::shoot(HepRandomEngine* anEngine,
double width) {
return width * anEngine->flat();
}
inline long RandFlat::shootInt(HepRandomEngine* anEngine,
long n) {
return long(anEngine->flat()*double(n));
}
inline long RandFlat::shootInt(HepRandomEngine* anEngine,
long a1, long n) {
return long(double(n-a1)*anEngine->flat()) + a1;
}
inline void RandFlat::shootArray(HepRandomEngine* anEngine,
const int size, double* vect) {
anEngine->flatArray(size,vect);
}
inline void RandFlat::shootBits(HepRandomEngine* engine) {
const double factor= 2.0*MSB; // this should fit into a double!
staticFirstUnusedBit= MSB;
staticRandomInt= (unsigned long)(factor*shoot(engine));
}
inline int RandFlat::shootBit(HepRandomEngine* engine) {
if (staticFirstUnusedBit==0)
shootBits(engine);
unsigned long temp= staticFirstUnusedBit&staticRandomInt;
staticFirstUnusedBit>>= 1;
return temp!=0;
}
//---------------------
inline double RandFlat::fire() {
return (defaultB-defaultA)*localEngine->flat()+defaultA;
}
inline double RandFlat::fire(double a, double b) {
return (b-a)* localEngine->flat() + a;
}
inline double RandFlat::fire(double width) {
return width * localEngine->flat();
}
inline long RandFlat::fireInt(long n) {
return long(localEngine->flat()*double(n));
}
inline long RandFlat::fireInt(long a1, long n) {
return long(localEngine->flat()*double(n-a1)) + a1;
}
inline void RandFlat::fireBits() {
const double factor= 2.0*MSB; // this should fit into a double!
firstUnusedBit= MSB;
randomInt= (unsigned long)(factor*localEngine->flat());
}
inline int RandFlat::fireBit() {
if (firstUnusedBit==0)
fireBits();
unsigned long temp= firstUnusedBit&randomInt;
firstUnusedBit>>= 1;
return temp!=0;
}
} // namespace CLHEP
|