4#include "CLHEP/Units/GlobalPhysicalConstants.h"
5#include "CLHEP/Random/Randomize.h"
6#include "CLHEP/Random/NonRandomEngine.h"
7#include "CLHEP/Random/defs.h"
14 std::ofstream
output(
"testEngineCopy.cout");
16 std::ostream &
output = std::cout;
24#define TEST_ENGINE_COPY
30 #pragma clang diagnostic push
31 #pragma clang diagnostic ignored "-Wunknown-warning-option"
32 #pragma clang diagnostic ignored "-Wunused-but-set-variable"
42 std::vector<double> ab(2);
48 std::vector<double> v;
51 for (
int i=0; i<n; i++) {
62 output <<
"Copy 64bit test for " << E::engineName() <<
"\n";
66 for (
int i=0; i<n; i++) x += e.flat();
69 output <<
"x = " << x << std::endl;
72 output <<
"y = " << y << std::endl;
73 if( x != y )
return n;
75 for(
int i=0; i<1000; ++i ) {
79 output <<
"i = " << i <<
" x, y " << x <<
" " << y
80 <<
" vectorTest64 problem: e != f \n";
92 std::vector<double> nonRand =
aSequence(500);
97 for (
int i=0; i<n; i++) x += e.
flat();
98 std::vector<unsigned long> v = e.
put();
101 output <<
"x = " << x << std::endl;
104 output <<
"y = " << y << std::endl;
105 if( x != y )
return n;
107 for(
int i=0; i<300; ++i ) {
108 if( e.
flat() !=
f.flat() ) {
109 output <<
"i = " << i <<
" vectorTest64 for NonRandomEngine problem: e != f \n";
119 output <<
"Copy for " << E::engineName() <<
"\n";
122 for (
int i=0; i<n; i++) r += e.flat();
124 for (
int j=0; j<25; j++) v.push_back(e.flat());
126 output <<
"First four of v are: "
127 << v[0] <<
", " << v[1] <<
", " << v[2] <<
", " << v[3] <<
"\n";
138 std::vector<double> nonRand =
aSequence(500);
142 for (
int i=0; i<n; i++) r += e.
flat();
144 for (
int j=0; j<25; j++) v.push_back(e.
flat());
146 output <<
"First four of v are: "
147 << v[0] <<
", " << v[1] <<
", " << v[2] <<
", " << v[3] <<
"\n";
155 std::vector<double> k;
156 for (
int j=0; j<25; j++) k.push_back(
f.flat());
158 output <<
"First four of k are: "
159 << k[0] <<
", " << k[1] <<
", " << k[2] <<
", " << k[3] <<
"\n";
161 for (
int m1=0; m1<25; m1++) {
162 if ( v[m1] != k[m1] ) {
163 std::cout <<
"???? Incorrect copy restored value for engine: "
164 << E::engineName() <<
"\n";
166 output <<
"???? Incorrect copy restored value for engine: "
167 << E::engineName() <<
"\n";
179 std::vector<double> v;
180 int status1 = vectorTest64<E>(n);
181 E
f = vectorRestore1<E>(n,v);
182 int status2 = vectorRestore2<E>(
f, v);
183 return (status1 | status2);
196#ifdef TEST_ENGINE_COPY
197 output <<
"\n=================================\n";
199 output <<
" Copy test of engines\n";
200 output <<
"=================================\n\n";
202 stat |= vectorRestore<DualRand>(113);
205 stat |= vectorRestore<Hurd160Engine>(115);
206 stat |= vectorRestore<Hurd288Engine>(116);
207 stat |= vectorRestore<HepJamesRandom>(117);
208 stat |= vectorRestore<MixMaxRng>(149);
209 stat |= vectorRestore<MTwistEngine>(118);
210 stat |= vectorRestore<RanecuEngine>(139);
211 stat |= vectorRestore<Ranlux64Engine>(119);
212 stat |= vectorRestore<RanluxEngine>(120);
213 stat |= vectorRestore<RanluxppEngine>(119);
214 stat |= vectorRestore<RanshiEngine>(121);
215 stat |= vectorRestore<TripleRand>(122);
216 stat |= vectorRestore<NonRandomEngine>(123);
221 output <<
"\n=============================================\n\n";
224 std::cout <<
"One or more problems detected: stat = " << stat <<
"\n";
225 output <<
"One or more problems detected: stat = " << stat <<
"\n";
227 output <<
"ranRestoreTest passed with no problems detected.\n";
230 if (stat == 0)
return 0;
231 if (stat > 0)
return -(stat|1);
236 #pragma clang diagnostic pop
virtual std::ostream & put(std::ostream &os) const
void setRandomSequence(double *s, int n)
static std::string engineName()
E vectorRestore1(int n, std::vector< double > &v)
int vectorRestore2(E &f, const std::vector< double > &v)
int vectorTest64< NonRandomEngine >(int n)
std::vector< double > aSequence(int n)
std::ofstream output("testEngineCopy.cout")
bool equals(double a, double b)
bool equals01(const std::vector< double > &ab)
NonRandomEngine vectorRestore1< NonRandomEngine >(int n, std::vector< double > &v)