The Gaudi Framework  master (37c0b60a)
Gaudi::Utils::QuasiRandom Namespace Reference

Functions

uint32_t mix (uint32_t state)
 Create a hash with a large avalanche effect from a 32 bit integer. More...
 
uint32_t mix32 (uint32_t state, uint32_t extra)
 mix some 'extra' entropy into 'state' and return result More...
 
uint32_t mix64 (uint32_t state, uint64_t extra)
 mix some 'extra' entropy into 'state' and return result More...
 
uint32_t mixString (uint32_t state, const std::string &extra)
 mix some 'extra' entropy into 'state' and return result More...
 

Function Documentation

◆ mix()

uint32_t Gaudi::Utils::QuasiRandom::mix ( uint32_t  state)

Create a hash with a large avalanche effect from a 32 bit integer.

Definition at line 21 of file QuasiRandom.cpp.

21  {
22  state += ( state << 16 );
23  state ^= ( state >> 13 );
24  state += ( state << 4 );
25  state ^= ( state >> 7 );
26  state += ( state << 10 );
27  state ^= ( state >> 5 );
28  state += ( state << 8 );
29  state ^= ( state >> 16 );
30  return state;
31  }

◆ mix32()

uint32_t Gaudi::Utils::QuasiRandom::mix32 ( uint32_t  state,
uint32_t  extra 
)

mix some 'extra' entropy into 'state' and return result

Definition at line 33 of file QuasiRandom.cpp.

33 { return mix( state + extra ); }

◆ mix64()

uint32_t Gaudi::Utils::QuasiRandom::mix64 ( uint32_t  state,
uint64_t  extra 
)

mix some 'extra' entropy into 'state' and return result

Definition at line 35 of file QuasiRandom.cpp.

35  {
36  typedef boost::low_bits_mask_t<32> mask_t;
37  state = mix32( state, uint32_t( extra & mask_t::sig_bits_fast ) );
38  return mix32( state, uint32_t( ( extra >> 32 ) & mask_t::sig_bits_fast ) );
39  }

◆ mixString()

uint32_t Gaudi::Utils::QuasiRandom::mixString ( uint32_t  state,
const std::string extra 
)

mix some 'extra' entropy into 'state' and return result

Definition at line 41 of file QuasiRandom.cpp.

41  {
42  // prefix name with ' ' until the size is a multiple of 4.
43  std::string s = std::string( ( 4 - extra.size() % 4 ) % 4, ' ' ) + extra;
44  for ( size_t i = 0; i < s.size() / 4; ++i ) {
45  // FIXME: this might do something different on big endian vs. small endian machines...
46  uint32_t x = uint32_t( s[i * 4] ) | uint32_t( s[i * 4 + 1] ) << 8 | uint32_t( s[i * 4 + 2] ) << 16 |
47  uint32_t( s[i * 4 + 3] ) << 24;
48  state = mix32( state, x );
49  }
50  return state;
51  }
std::string
STL class.
gaudirun.s
string s
Definition: gaudirun.py:346
std::string::size
T size(T... args)
Gaudi::Utils::QuasiRandom::mix32
uint32_t mix32(uint32_t state, uint32_t extra)
mix some 'extra' entropy into 'state' and return result
Definition: QuasiRandom.cpp:33
Gaudi::Utils::QuasiRandom::mix
uint32_t mix(uint32_t state)
Create a hash with a large avalanche effect from a 32 bit integer.
Definition: QuasiRandom.cpp:21
compareRootHistos.state
state
Definition: compareRootHistos.py:496