CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
testDistCopy.cc File Reference
#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Random/DualRand.h"
#include "CLHEP/Random/MTwistEngine.h"
#include "CLHEP/Random/RandBinomial.h"
#include "CLHEP/Random/RandBreitWigner.h"
#include "CLHEP/Random/RandChiSquare.h"
#include "CLHEP/Random/RandExponential.h"
#include "CLHEP/Random/RandFlat.h"
#include "CLHEP/Random/RandGamma.h"
#include "CLHEP/Random/RandGauss.h"
#include "CLHEP/Random/RandGaussQ.h"
#include "CLHEP/Random/RandGaussT.h"
#include "CLHEP/Random/RandGeneral.h"
#include "CLHEP/Random/RandLandau.h"
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandPoissonT.h"
#include "CLHEP/Random/RandSkewNormal.h"
#include "CLHEP/Random/RandStudentT.h"
#include <sstream>
#include <string>
#include <vector>

Go to the source code of this file.

Typedefs

typedef unsigned int uint
 

Functions

template<typename Dist >
bool copy_constructor_is_okay (Dist &d1)
 
template<typename Dist >
bool copy_assignment_is_okay (Dist &d1, Dist &d2)
 
uint testRandBinomial ()
 
uint testRandBreitWigner ()
 
uint testRandChiSquare ()
 
uint testRandExponential ()
 
uint testRandFlat ()
 
uint testRandGamma ()
 
uint testRandGauss ()
 
uint testRandGaussQ ()
 
uint testRandGaussT ()
 
uint testRandGeneral ()
 
uint testRandLandau ()
 
uint testRandPoisson ()
 
uint testRandPoissonQ ()
 
uint testRandPoissonT ()
 
uint testRandSkewNormal ()
 
uint testRandStudentT ()
 
int main ()
 

Typedef Documentation

◆ uint

typedef unsigned int uint

Definition at line 43 of file testDistCopy.cc.

Function Documentation

◆ copy_assignment_is_okay()

template<typename Dist >
bool copy_assignment_is_okay ( Dist &  d1,
Dist &  d2 
)

Definition at line 78 of file testDistCopy.cc.

79{
80 // prime the distributions
81 for( uint i = 0u; i != 17u; ++i )
82 (void) d1.fire();
83 for( uint i = 0u; i != 19u; ++i )
84 (void) d2.fire();
85
86 // capture d1's state
87 std::ostringstream os1;
88 d1.put( os1 );
89 HepRandomEngine * e1 = & d1.engine();
90
91 // make a copy and capture the copy's state
92 d2 = d1;
93 std::ostringstream os2;
94 d2.put( os2 );
95 HepRandomEngine * e2 = & d2.engine();
96
97 // do the saved states match and is the underlying engine shared?
98 return os1.str() == os2.str() && e1 == e2;
99} // copy_assignment_is_okay<>()
virtual std::ostream & put(std::ostream &os) const
Definition: RandomEngine.cc:61
unsigned int uint
Definition: testDistCopy.cc:43

Referenced by testRandBinomial(), testRandBreitWigner(), testRandChiSquare(), testRandExponential(), testRandFlat(), testRandGamma(), testRandGauss(), testRandGaussQ(), testRandGaussT(), testRandGeneral(), testRandLandau(), testRandPoisson(), testRandPoissonQ(), testRandPoissonT(), testRandSkewNormal(), and testRandStudentT().

◆ copy_constructor_is_okay()

template<typename Dist >
bool copy_constructor_is_okay ( Dist &  d1)

Definition at line 51 of file testDistCopy.cc.

52{
53 // prime the distribution
54 for( uint i = 0u; i != 17u; ++i )
55 (void) d1.fire();
56
57 // capture its state
58 std::ostringstream os1;
59 d1.put( os1 );
60 HepRandomEngine * e1 = & d1.engine();
61
62 // make a copy and capture the copy's state
63 Dist d2( d1 );
64 std::ostringstream os2;
65 d2.put( os2 );
66 HepRandomEngine * e2 = & d2.engine();
67
68 // do the saved states match and is the underlying engine shared?
69 return os1.str() == os2.str() && e1 == e2;
70} // copy_constructor_is_okay<>()

Referenced by testRandBinomial(), testRandBreitWigner(), testRandChiSquare(), testRandExponential(), testRandFlat(), testRandGamma(), testRandGauss(), testRandGaussQ(), testRandGaussT(), testRandGeneral(), testRandLandau(), testRandPoisson(), testRandPoissonQ(), testRandPoissonT(), testRandSkewNormal(), and testRandStudentT().

◆ main()

int main ( )

Definition at line 401 of file testDistCopy.cc.

402{
403 uint mask = 0u
408 | testRandFlat ()
409 | testRandGamma ()
410 | testRandGauss ()
411 | testRandGaussQ ()
412 | testRandGaussT ()
413 | testRandGeneral ()
414 | testRandLandau ()
415 | testRandPoisson ()
420 ;
421
422 return - int(mask);
423}
uint testRandFlat()
uint testRandPoissonQ()
uint testRandGaussQ()
uint testRandGeneral()
uint testRandPoissonT()
uint testRandLandau()
uint testRandBreitWigner()
uint testRandGauss()
uint testRandPoisson()
uint testRandChiSquare()
uint testRandGaussT()
uint testRandBinomial()
uint testRandGamma()
uint testRandSkewNormal()
uint testRandStudentT()
uint testRandExponential()

◆ testRandBinomial()

uint testRandBinomial ( )

Definition at line 127 of file testDistCopy.cc.

128{
129 MTwistEngine r1( 97531L );
130 RandBinomial d1( r1 );
131 if( ! copy_constructor_is_okay(d1) ) return Binomial_failure;
132
133 DualRand r2( 13579L );
134 RandBinomial d2( r2 );
135 if( ! copy_assignment_is_okay(d1,d2) ) return Binomial_failure;
136
137 return 0u;
138}
bool copy_assignment_is_okay(Dist &d1, Dist &d2)
Definition: testDistCopy.cc:78
bool copy_constructor_is_okay(Dist &d1)
Definition: testDistCopy.cc:51

Referenced by main().

◆ testRandBreitWigner()

uint testRandBreitWigner ( )

Definition at line 144 of file testDistCopy.cc.

145{
146 MTwistEngine r1( 97531L );
147 RandBreitWigner d1( r1 );
148 if( ! copy_constructor_is_okay(d1) ) return BreitWigner_failure;
149
150 DualRand r2( 13579L );
151 RandBreitWigner d2( r2 );
152 if( ! copy_assignment_is_okay(d1,d2) ) return BreitWigner_failure;
153
154 return 0u;
155} // testRandBreitWigner

Referenced by main().

◆ testRandChiSquare()

uint testRandChiSquare ( )

Definition at line 161 of file testDistCopy.cc.

162{
163 MTwistEngine r1( 97531L );
164 RandChiSquare d1( r1 );
165 if( ! copy_constructor_is_okay(d1) ) return ChiSquare_failure;
166
167 DualRand r2( 13579L );
168 RandChiSquare d2( r2 );
169 if( ! copy_assignment_is_okay(d1,d2) ) return ChiSquare_failure;
170
171 return 0u;
172} // testRandChiSquare

Referenced by main().

◆ testRandExponential()

uint testRandExponential ( )

Definition at line 178 of file testDistCopy.cc.

179{
180 MTwistEngine r1( 97531L );
181 RandExponential d1( r1 );
182 if( ! copy_constructor_is_okay(d1) ) return Exponential_failure;
183
184 DualRand r2( 13579L );
185 RandExponential d2( r2 );
186 if( ! copy_assignment_is_okay(d1,d2) ) return Exponential_failure;
187
188 return 0u;
189} // testRandExponential

Referenced by main().

◆ testRandFlat()

uint testRandFlat ( )

Definition at line 195 of file testDistCopy.cc.

196{
197 MTwistEngine r1( 97531L );
198 RandFlat d1( r1 );
199 if( ! copy_constructor_is_okay(d1) ) return Flat_failure;
200
201 DualRand r2( 13579L );
202 RandFlat d2( r2 );
203 if( ! copy_assignment_is_okay(d1,d2) ) return Flat_failure;
204
205 return 0u;
206} // testRandFlat

Referenced by main().

◆ testRandGamma()

uint testRandGamma ( )

Definition at line 212 of file testDistCopy.cc.

213{
214 MTwistEngine r1( 97531L );
215 RandGamma d1( r1 );
216 if( ! copy_constructor_is_okay(d1) ) return Gamma_failure;
217
218 DualRand r2( 13579L );
219 RandGamma d2( r2 );
220 if( ! copy_assignment_is_okay(d1,d2) ) return Gamma_failure;
221
222 return 0u;
223} // testRandGamma

Referenced by main().

◆ testRandGauss()

uint testRandGauss ( )

Definition at line 229 of file testDistCopy.cc.

230{
231 MTwistEngine r1( 97531L );
232 RandGauss d1( r1 );
233 if( ! copy_constructor_is_okay(d1) ) return Gauss_failure;
234
235 DualRand r2( 13579L );
236 RandGauss d2( r2 );
237 if( ! copy_assignment_is_okay(d1,d2) ) return Gauss_failure;
238
239 return 0u;
240} // testRandGauss

Referenced by main().

◆ testRandGaussQ()

uint testRandGaussQ ( )

Definition at line 246 of file testDistCopy.cc.

247{
248 MTwistEngine r1( 97531L );
249 RandGaussQ d1( r1 );
250 if( ! copy_constructor_is_okay(d1) ) return GaussQ_failure;
251
252 DualRand r2( 13579L );
253 RandGaussQ d2( r2 );
254 if( ! copy_assignment_is_okay(d1,d2) ) return GaussQ_failure;
255
256 return 0u;
257} // testRandGaussQ

Referenced by main().

◆ testRandGaussT()

uint testRandGaussT ( )

Definition at line 263 of file testDistCopy.cc.

264{
265 MTwistEngine r1( 97531L );
266 RandGaussT d1( r1 );
267 if( ! copy_constructor_is_okay(d1) ) return GaussT_failure;
268
269 DualRand r2( 13579L );
270 RandGaussT d2( r2 );
271 if( ! copy_assignment_is_okay(d1,d2) ) return GaussT_failure;
272
273 return 0u;
274} // testRandGaussT

Referenced by main().

◆ testRandGeneral()

uint testRandGeneral ( )

Definition at line 280 of file testDistCopy.cc.

281{
282 MTwistEngine r1( 97531L );
283 double pdf1[] = { 1.5, 2.5, 3.0, 4.25, 5.65 };
284 RandGeneral d1( r1, pdf1, sizeof(pdf1)/sizeof(pdf1[0]) );
285 if( ! copy_constructor_is_okay(d1) ) return General_failure;
286
287 DualRand r2( 13579L );
288 double pdf2[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 0.60 };
289 RandGeneral d2( r2, pdf2, sizeof(pdf2)/sizeof(pdf2[0]) );
290 if( ! copy_assignment_is_okay(d1,d2) ) return General_failure;
291
292 return 0u;
293} // testRandGeneral

Referenced by main().

◆ testRandLandau()

uint testRandLandau ( )

Definition at line 299 of file testDistCopy.cc.

300{
301 MTwistEngine r1( 97531L );
302 RandLandau d1( r1 );
303 if( ! copy_constructor_is_okay(d1) ) return Landau_failure;
304
305 DualRand r2( 13579L );
306 RandLandau d2( r2 );
307 if( ! copy_assignment_is_okay(d1,d2) ) return Landau_failure;
308
309 return 0u;
310} // testRandLandau

Referenced by main().

◆ testRandPoisson()

uint testRandPoisson ( )

Definition at line 316 of file testDistCopy.cc.

317{
318 MTwistEngine r1( 97531L );
319 RandPoisson d1( r1 );
320 if( ! copy_constructor_is_okay(d1) ) return Poisson_failure;
321
322 DualRand r2( 13579L );
323 RandPoisson d2( r2 );
324 if( ! copy_assignment_is_okay(d1,d2) ) return Poisson_failure;
325
326 return 0u;
327} // testRandPoisson

Referenced by main().

◆ testRandPoissonQ()

uint testRandPoissonQ ( )

Definition at line 333 of file testDistCopy.cc.

334{
335 MTwistEngine r1( 97531L );
336 RandPoissonQ d1( r1 );
337 if( ! copy_constructor_is_okay(d1) ) return PoissonQ_failure;
338
339 DualRand r2( 13579L );
340 RandPoissonQ d2( r2 );
341 if( ! copy_assignment_is_okay(d1,d2) ) return PoissonQ_failure;
342
343 return 0u;
344} // testRandPoissonQ

Referenced by main().

◆ testRandPoissonT()

uint testRandPoissonT ( )

Definition at line 350 of file testDistCopy.cc.

351{
352 MTwistEngine r1( 97531L );
353 RandPoissonT d1( r1 );
354 if( ! copy_constructor_is_okay(d1) ) return PoissonT_failure;
355
356 DualRand r2( 13579L );
357 RandPoissonT d2( r2 );
358 if( ! copy_assignment_is_okay(d1,d2) ) return PoissonT_failure;
359
360 return 0u;
361} // testRandPoissonT

Referenced by main().

◆ testRandSkewNormal()

uint testRandSkewNormal ( )

Definition at line 367 of file testDistCopy.cc.

368{
369 MTwistEngine r1( 97531L );
370 RandSkewNormal d1( r1 );
371 if( ! copy_constructor_is_okay(d1) ) return SkewNormal_failure;
372
373 DualRand r2( 13579L );
374 RandSkewNormal d2( r2 );
375 if( ! copy_assignment_is_okay(d1,d2) ) return SkewNormal_failure;
376
377 return 0u;
378} // testRandSkewNormal

Referenced by main().

◆ testRandStudentT()

uint testRandStudentT ( )

Definition at line 384 of file testDistCopy.cc.

385{
386 MTwistEngine r1( 97531L );
387 RandStudentT d1( r1 );
388 if( ! copy_constructor_is_okay(d1) ) return StudentT_failure;
389
390 DualRand r2( 13579L );
391 RandStudentT d2( r2 );
392 if( ! copy_assignment_is_okay(d1,d2) ) return StudentT_failure;
393
394 return 0u;
395} // testRandStudentT

Referenced by main().