76 {
77
78 cout << "Enter 1 for RandGauss, 2 for RandGaussQ, 3 for DualRand flat: ";
79 int choice;
80 cin >> choice;
81
82if (choice==1) {
83 cout << "\n--------------------------------------------\n";
84 cout << "Test of Gauss distribution speed\n\n";
85
86 long seed;
87 cout << "Please enter an integer seed: ";
88 cin >> seed;
89
90 int nNumbers;
91 cout << "How many numbers should we generate: ";
92 cin >> nNumbers;
93
94 cout << "\nInstantiating distribution utilizing DualRand engine...\n";
97
98 double sum = 0;
99
100
101 for (int i=0; i < nNumbers; i++) {
102 sum += dist.fire();
103 }
104
105 cout << "\n Finished: sum is " << sum << " \n";
106}
107
108if (choice==2) {
109 cout << "\n--------------------------------------------\n";
110 cout << "Test of RandGaussQ distribution speed\n\n";
111
112 long seed;
113 cout << "Please enter an integer seed: ";
114 cin >> seed;
115
116 int nNumbers;
117 cout << "How many numbers should we generate: ";
118 cin >> nNumbers;
119
120 cout << "\nInstantiating distribution utilizing DualRand engine...\n";
123
124 double sum = 0;
125
126
127 for (int i=0; i < nNumbers; i++) {
128 sum += dist.fire();
129 }
130
131 cout << "\n Finished: sum is " << sum << " \n";
132}
133
134if (choice==3) {
135 cout << "\n--------------------------------------------\n";
136 cout << "Test of DualRand flat speed\n\n";
137
138 long seed;
139 cout << "Please enter an integer seed: ";
140 cin >> seed;
141
142 int nNumbers;
143 cout << "How many numbers should we generate: ";
144 cin >> nNumbers;
145
146 cout << "\nInstantiating distribution utilizing DualRand engine...\n";
148
149 double sum = 0;
150
151
152 for (int i=0; i < nNumbers; i++) {
153 sum += eng.flat();
154 }
155
156 cout << "\n Finished: sum is " << sum << " \n";
157}
158␌
159
160#ifdef GAMMA
161 cout << "\nNow we will compute the first 20 gammas, using gammln:\n";
162
163 double x;
164 for (x=1; x <= 20; x+=1) {
165 cout << x << std::setprecision(20) <<
" " << std::exp(
gammln1(x))
166 <<
" " << std::exp(
gammln2(x)) <<
" difference in gammln2 = " <<
168 }
169
170
171 cout << "\nNow we will compute gamma of small numbers: \n";
172
173 for ( x=1; x > .000000001; x *= .9 ) {
174 cout << x << std::setprecision(20) << " " <<
175 1 - std::exp(
gammln1(x)) * std::exp(
gammln1(2-x)) * std::sin(CLHEP::pi*(1-x)) / (CLHEP::pi*(1-x)) <<
176 " " <<
177 1 - std::exp(
gammln2(x)) * std::exp(
gammln1(2-x)) * std::sin(CLHEP::pi*(1-x)) / (CLHEP::pi*(1-x)) <<
178 "\n";
179 }
180#endif
181
182#ifdef POISSON
183 cout << "\n--------------------------------------------\n";
184 cout << "Test of Poisson distribution speed\n\n";
185
186 long seed;
187 cout << "Please enter an integer seed: ";
188 cin >> seed;
189
190 double mu;
191 cout << "Please enter mu: ";
192 cin >> mu;
193
194 int nNumbers;
195 cout << "How many numbers should we generate: ";
196 cin >> nNumbers;
197
198 cout << "\nInstantiating distribution utilizing DualRand engine...\n";
201
202
203 double sum = 0;
204
205
206 for (int i=0; i < nNumbers; i++) {
207 sum += dist.fire();
208
209
210
211
212 }
213
214 cout << "\n Finished: sum is " << sum << " \n";
215#endif
216
217␌
218#define MISC
219#ifdef MISC
220
222
223
224
227 cout << "testing RandGaussT::shoot(100,10): " <<
229 cout << "testing RandGaussT::shoot(&e,100,10): " <<
232 cout << "testing gt.fire(): " << gt.fire() << "\n";
233 cout << "testing gt.fire(200,2): " << gt.fire(200,2) << "\n";
234
237 cout << "testing RandGaussQ::shoot(100,10): " <<
239 cout << "testing RandGaussQ::shoot(&e,100,10): " <<
242 cout << "testing qt.fire(): " << qt.fire() << "\n";
243 cout << "testing qt.fire(200,2): " << qt.fire(200,2) << "\n";
244
245
246
248 cout << "testing RandPoissonT::shoot(&e): "
250 cout << "testing RandPoissonT::shoot(90): " <<
252 cout << "testing RandPoissonT::shoot(&e,90): " <<
255 cout << "testing pgt.fire(): " << pgt.fire() << "\n";
256 cout << "testing pgt.fire(20): " << pgt.fire(20) << "\n";
257
260 cout << "testing RandPoissonQ::shoot(90): " <<
262 cout << "testing RandPoissonQ::shoot(&e,90): " <<
265 cout << "testing pqt.fire(): " << pqt.fire() << "\n";
266 cout << "testing pqt.fire(20): " << pqt.fire(20) << "\n";
267
268
269
270 cout << "testing RandBit::shoot(): " << RandBit::shoot() << "\n";
271 cout << "testing RandBit::shoot(&e): " << RandBit::shoot(&e) << "\n";
272 cout << "testing RandBit::shoot(10,20): " << RandBit::shoot(10,20) << "\n";
273 cout << "testing RandBit::shoot(&e,10,20): "<<
274 RandBit::shoot(&e,10,20) << "\n";
276 cout << "testing b.fire(): " << b.fire() << "\n";
277 cout << "testing b.fire(10,20): " << b.fire(10,20) << "\n";
278 int i;
279 cout << "testing RandBit::shootBit(): ";
280 for (i=0; i<40; i++) {
282 } cout << "\n";
283 cout << "testing RandBit::shootBit(&e): ";
284 for (i=0; i<40; i++) {
286 } cout << "\n";
287 cout << "testing RandBit::fireBit(): ";
288 for (i=0; i<40; i++) {
289 cout << b.fireBit();
290 } cout << "\n";
291
292
293
294 cout << "Timing RandFlat::shootBit(): Enter N: ";
295 int N;
296 cin >> N;
297 int sum=0;
298 for (i=0; i<N; i++) {
300 }
301 cout << "--------- Done.............. Sum = " << sum << "\n";
302 cout << "Timing RandBit::shootBit(): Enter N: ";
303 cin >> N;
304 sum = 0;
305 for (i=0; i<N; i++) {
307 }
308 cout << "--------- Done.............. Sum = " << sum << "\n";
309
310#endif
311
312 return 0;
313}
static long shoot(double mean=1.0)
static long shoot(double mean=1.0)
double gammln2(double xx)
double gammln1(double xx)