| The Gaudi Framework v32r1 (f65d50dc)

QuasiRandom.cpp
Go to the documentation of this file.
1 // Include files
2 #include <string>
3
4 // local
5 #include "GaudiUtils/QuasiRandom.h"
6
7 namespace Gaudi {
8 namespace Utils {
9 namespace QuasiRandom {
10
11 uint32_t mix( uint32_t state ) {
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
25 uint32_t mix64( uint32_t state, uint64_t extra ) {
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
31 uint32_t mixString( uint32_t state, const std::string& extra ) {
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
Gaudi::Utils::QuasiRandom::mixString
uint32_t mixString(uint32_t state, const std::string &extra)
mix some 'extra' entropy into 'state' and return result
Definition: QuasiRandom.cpp:31
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:11
uint64_t
unsigned long long uint64_t
Definition: instrset.h:143
std::string
STL class.
compareRootHistos.state
def state
Definition: compareRootHistos.py:455
uint32_t
unsigned int uint32_t
Definition: instrset.h:141
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:23
gaudirun.s
string s
Definition: gaudirun.py:316
QuasiRandom.h
Gaudi::Utils::QuasiRandom::mix64
uint32_t mix64(uint32_t state, uint64_t extra)
mix some 'extra' entropy into 'state' and return result
Definition: QuasiRandom.cpp:25
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1