Commit 31505110 authored by Lynn Garren's avatar Lynn Garren

address sr #125918 and bug #86228

parent 0208f3b4
2012-02-03 Lynn Garren <garren@fnal.gov>
* Random/src/Ranlux64Engine.cc: use a template to get rid of the warnings
2012-02-02 Lynn Garren <garren@fnal.gov>
......
2012-02-03 Lynn Garren <garren@fnal.gov>
* src/Ranlux64Engine.cc: use a template to get rid of the warnings
2012-02-01 Lynn Garren <garren@fnal.gov>
* change the names of internal variables so -Wshadow does not complain
......
......@@ -74,6 +74,28 @@ int Ranlux64Engine::numEngines = 0;
// Maximum index into the seed table
int Ranlux64Engine::maxIndex = 215;
namespace detail {
template< std::size_t n,
bool = n < std::size_t(std::numeric_limits<unsigned long>::digits) >
struct do_right_shift;
template< std::size_t n >
struct do_right_shift<n,true>
{
unsigned long operator()(unsigned long value) { return value >> n; }
};
template< std::size_t n >
struct do_right_shift<n,false>
{
unsigned long operator()(unsigned long) { return 0ul; }
};
template< std::size_t nbits >
unsigned long rshift( unsigned long value )
{ return do_right_shift<nbits>()(value); }
} // namespace detail
std::string Ranlux64Engine::name() const {return "Ranlux64Engine";}
Ranlux64Engine::Ranlux64Engine()
......@@ -396,8 +418,10 @@ void Ranlux64Engine::setSeed(long seed, int lux) {
// are we on a 64bit machine?
if( sizeof(long) >= 8 ) {
long topbits1, topbits2;
topbits1 = ( seed >> 32) & 0xffff ;
topbits2 = ( seed >> 48) & 0xffff ;
//topbits1 = ( seed >> 32) & 0xffff ;
//topbits2 = ( seed >> 48) & 0xffff ;
topbits1 = detail::rshift<32>(seed) & 0xffff ;
topbits2 = detail::rshift<48>(seed) & 0xffff ;
init_table[0] ^= topbits1;
init_table[2] ^= topbits2;
//std::cout << " init_table[0] " << init_table[0] << " from " << topbits1 << std::endl;
......
......@@ -1125,7 +1125,7 @@ int testRandGeneral() {
{ // Open block for testing type 1 - step function pdf
RandGeneral dist (eng, aProbFunc, nBins, 1);
delete aProbFunc;
delete[] aProbFunc;
double* garbage = new double[nBins];
// We wish to verify that deleting the pdf
......@@ -1143,7 +1143,7 @@ int testRandGeneral() {
good = gaussianTest ( dist, mu, sigma, nNumbers );
delete garbage;
delete[] garbage;
} // Close block for testing type 1 - step function pdf
// dist goes out of scope but eng is supposed to stick around;
......
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