Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QuasiRandom.cpp
Go to the documentation of this file.
1 // Include files
2 #include <string>
3 
4 // local
6 
7 namespace Gaudi {
8  namespace Utils {
9  namespace QuasiRandom {
10 
12  state += ( state << 16 );
13  state ^= ( state >> 13 );
14  state += ( state << 4 );
15  state ^= ( state >> 7 );
16  state += ( state << 10 );
17  state ^= ( state >> 5 );
18  state += ( state << 8 );
19  state ^= ( state >> 16 );
20  return state;
21  }
22 
23  uint32_t mix32( uint32_t state, uint32_t extra ) { return mix( state + extra ); }
24 
26  typedef boost::low_bits_mask_t<32> mask_t;
27  state = mix32( state, uint32_t( extra & mask_t::sig_bits_fast ) );
28  return mix32( state, uint32_t( ( extra >> 32 ) & mask_t::sig_bits_fast ) );
29  }
30 
32  // prefix name with ' ' until the size is a multiple of 4.
33  std::string s = std::string( ( 4 - extra.size() % 4 ) % 4, ' ' ) + extra;
34  for ( size_t i = 0; i < s.size() / 4; ++i ) {
35  // FIXME: this might do something different on big endian vs. small endian machines...
36  uint32_t x = uint32_t( s[i * 4] ) | uint32_t( s[i * 4 + 1] ) << 8 | uint32_t( s[i * 4 + 2] ) << 16 |
37  uint32_t( s[i * 4 + 3] ) << 24;
38  state = mix32( state, x );
39  }
40  return state;
41  }
42  } // namespace QuasiRandom
43  } // namespace Utils
44 } // namespace Gaudi
uint32_t mixString(uint32_t state, const std::string &extra)
mix some &#39;extra&#39; entropy into &#39;state&#39; and return result
Definition: QuasiRandom.cpp:31
uint32_t mix(uint32_t state)
Create a hash with a large avalanche effect from a 32 bit integer.
Definition: QuasiRandom.cpp:11
unsigned long long uint64_t
Definition: instrset.h:143
STL class.
unsigned int uint32_t
Definition: instrset.h:141
T size(T...args)
uint32_t mix32(uint32_t state, uint32_t extra)
mix some &#39;extra&#39; entropy into &#39;state&#39; and return result
Definition: QuasiRandom.cpp:23
string s
Definition: gaudirun.py:312
uint32_t mix64(uint32_t state, uint64_t extra)
mix some &#39;extra&#39; entropy into &#39;state&#39; and return result
Definition: QuasiRandom.cpp:25
Helper functions to set/get the application return code.
Definition: __init__.py:1