Commit 04a4c600 authored by Lynn Garren's avatar Lynn Garren

test for bug #44156

parent 1630ee64
2008-11-18 Lynn Garren <garren@fnal.gov>
* Random/test/testVectorSave.cc: Add a test for bug #44156
2008-11-13 Mark Fischler <mf@fnal.gov>
* Random/src/engineIDulong.cc: Fix problem that caused check for proper
engine type to fail where an unsigned long is 64bits. (bug #44156)
* Random/src/*Engine.cc: make sure that existing stored engine states
don't break due to the change in engineIDulong.cc
==============================
04.11.08 Release CLHEP-2.0.4.1
==============================
......
2008-11-18 Lynn Garren <garren@fnal.gov>
* test/testVectorSave.cc: Add a test for bug #44156
2008-11-13 Mark Fischler <mf@fnal.gov>
* src/engineIDulong.cc: fix a problem for 64bit machines
* src/*Engine.cc: protection against the 64bit problem for states
that may have been previously saved
* src/engineIDulong.cc: Fix problem that caused check for proper
engine type to fail where an unsigned long is 64bits. (bug #44156)
* src/*Engine.cc: make sure that existing stored engine states
don't break due to the change in engineIDulong.cc
==============================
04.11.08 Release CLHEP-2.0.4.1
......
// -*- C++ -*-
// $Id: testVectorSave.cc,v 1.1.4.1 2005/04/15 16:32:53 garren Exp $
// $Id: testVectorSave.cc,v 1.1.4.1.2.1 2008/11/18 22:09:51 garren Exp $
// ----------------------------------------------------------------------
#include "CLHEP/Random/Randomize.h"
#include "CLHEP/Random/NonRandomEngine.h"
......@@ -50,6 +50,55 @@ std::vector<double> aSequence(int n) {
// ----------- Vector restore of engines -----------
// test the problem reported in bug #44156
// Note that this test always works on a 32bit machine
template <class E>
int vectorTest64(int n) {
output << "Vector restore 64bit test for " << E::engineName() << "\n";
E e;
double x = 0;
for (int i=0; i<n; i++) x += e.flat();
std::vector<unsigned long> v = e.put();
x = e.flat();
output << "x = " << x << std::endl;
E f;
v[0] &= 0xffffffffUL;
f.get(v);
double y = f.flat();
output << "y = " << y << std::endl;
if( x != y ) return n;
return 0;
}
// special case for NonRandomEngine
template <>
int vectorTest64<NonRandomEngine>(int n) {
output << "Vector restore 64bit test for " << NonRandomEngine::engineName() << "\n";
std::vector<double> nonRand = aSequence(500);
NonRandomEngine e;
e.setRandomSequence(&nonRand[0], nonRand.size());
double x = 0;
for (int i=0; i<n; i++) x += e.flat();
std::vector<unsigned long> v = e.put();
x = e.flat();
output << "x = " << x << std::endl;
NonRandomEngine f;
f.setRandomSequence(&nonRand[0], nonRand.size());
v[0] &= 0xffffffffUL;
f.get(v);
double y = f.flat();
output << "y = " << y << std::endl;
if( x != y ) return n;
return 0;
}
template <class E>
std::vector<unsigned long> vectorRestore1(int n, std::vector<double> & v) {
output << "Vector restore for " << E::engineName() << "\n";
......@@ -141,8 +190,10 @@ int vectorRestore2(const std::vector<unsigned long> state,
template <class E>
int vectorRestore(int n) {
std::vector<double> v;
int status1 = vectorTest64<E>(n);
std::vector<unsigned long> state = vectorRestore1<E>(n,v);
return vectorRestore2<E>(state, v);
int status2 = vectorRestore2<E>(state, v);
return (status1 | status2);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment