Warning, file /include/CLHEP/Random/RandFlat.icc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 namespace CLHEP {
0023
0024 inline RandFlat::RandFlat(HepRandomEngine & anEngine)
0025 : HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
0026 defaultWidth(1.0), defaultA(0.0), defaultB(1.0) {}
0027
0028 inline RandFlat::RandFlat(HepRandomEngine & anEngine, double width )
0029 : HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
0030 defaultWidth(width), defaultA(0.0), defaultB(width) {}
0031
0032 inline RandFlat::RandFlat(HepRandomEngine & anEngine, double a,
0033 double b )
0034 : HepRandom(), firstUnusedBit(0), localEngine(&anEngine, do_nothing_deleter()),
0035 defaultWidth(b-a), defaultA(a), defaultB(b) {}
0036
0037 inline RandFlat::RandFlat(HepRandomEngine * anEngine)
0038 : HepRandom(), firstUnusedBit(0), localEngine(anEngine),
0039 defaultWidth(1.0), defaultA(0.0), defaultB(1.0) {}
0040
0041 inline RandFlat::RandFlat(HepRandomEngine * anEngine, double width )
0042 : HepRandom(), firstUnusedBit(0), localEngine(anEngine),
0043 defaultWidth(width), defaultA(0.0), defaultB(width) {}
0044
0045 inline RandFlat::RandFlat(HepRandomEngine * anEngine, double a,
0046 double b )
0047 : HepRandom(), firstUnusedBit(0), localEngine(anEngine),
0048 defaultWidth(b-a), defaultA(a), defaultB(b) {}
0049
0050 inline double RandFlat::shoot(double a, double b) {
0051 return (b-a)* shoot() + a;
0052 }
0053
0054 inline double RandFlat::shoot(double width) {
0055 return width * shoot();
0056 }
0057
0058 inline long RandFlat::shootInt(long n) {
0059 return long(shoot()*double(n));
0060 }
0061
0062 inline long RandFlat::shootInt(long a1, long n) {
0063 return long(shoot()*double(n-a1)) + a1;
0064 }
0065
0066 inline void RandFlat::shootBits() {
0067 const double factor= 2.0*MSB;
0068 staticFirstUnusedBit= MSB;
0069 staticRandomInt= (unsigned long)(factor*shoot());
0070 }
0071
0072 inline int RandFlat::shootBit() {
0073 if (staticFirstUnusedBit==0)
0074 shootBits();
0075 unsigned long temp= staticFirstUnusedBit&staticRandomInt;
0076 staticFirstUnusedBit>>= 1;
0077 return temp!=0;
0078 }
0079
0080
0081
0082 inline double RandFlat::shoot(HepRandomEngine* anEngine) {
0083 return anEngine->flat();
0084 }
0085
0086
0087 inline double RandFlat::shoot(HepRandomEngine* anEngine,
0088 double a, double b) {
0089 return (b-a)* anEngine->flat() + a;
0090 }
0091
0092 inline double RandFlat::shoot(HepRandomEngine* anEngine,
0093 double width) {
0094 return width * anEngine->flat();
0095 }
0096
0097 inline long RandFlat::shootInt(HepRandomEngine* anEngine,
0098 long n) {
0099 return long(anEngine->flat()*double(n));
0100 }
0101
0102 inline long RandFlat::shootInt(HepRandomEngine* anEngine,
0103 long a1, long n) {
0104 return long(double(n-a1)*anEngine->flat()) + a1;
0105 }
0106
0107 inline void RandFlat::shootArray(HepRandomEngine* anEngine,
0108 const int size, double* vect) {
0109 anEngine->flatArray(size,vect);
0110 }
0111
0112 inline void RandFlat::shootBits(HepRandomEngine* engine) {
0113 const double factor= 2.0*MSB;
0114 staticFirstUnusedBit= MSB;
0115 staticRandomInt= (unsigned long)(factor*shoot(engine));
0116 }
0117
0118 inline int RandFlat::shootBit(HepRandomEngine* engine) {
0119 if (staticFirstUnusedBit==0)
0120 shootBits(engine);
0121 unsigned long temp= staticFirstUnusedBit&staticRandomInt;
0122 staticFirstUnusedBit>>= 1;
0123 return temp!=0;
0124 }
0125
0126
0127
0128 inline double RandFlat::fire() {
0129 return (defaultB-defaultA)*localEngine->flat()+defaultA;
0130 }
0131
0132 inline double RandFlat::fire(double a, double b) {
0133 return (b-a)* localEngine->flat() + a;
0134 }
0135
0136 inline double RandFlat::fire(double width) {
0137 return width * localEngine->flat();
0138 }
0139
0140 inline long RandFlat::fireInt(long n) {
0141 return long(localEngine->flat()*double(n));
0142 }
0143
0144 inline long RandFlat::fireInt(long a1, long n) {
0145 return long(localEngine->flat()*double(n-a1)) + a1;
0146 }
0147
0148 inline void RandFlat::fireBits() {
0149 const double factor= 2.0*MSB;
0150 firstUnusedBit= MSB;
0151 randomInt= (unsigned long)(factor*localEngine->flat());
0152 }
0153
0154 inline int RandFlat::fireBit() {
0155 if (firstUnusedBit==0)
0156 fireBits();
0157 unsigned long temp= firstUnusedBit&randomInt;
0158 firstUnusedBit>>= 1;
0159 return temp!=0;
0160 }
0161
0162 }