| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
9 namespace Utils
10 {
11 namespace QuasiRandom
12 {
13
14 uint32_t mix( uint32_t state )
15 {
16 state += ( state << 16 );
17 state ^= ( state >> 13 );
18 state += ( state << 4 );
19 state ^= ( state >> 7 );
20 state += ( state << 10 );
21 state ^= ( state >> 5 );
22 state += ( state << 8 );
23 state ^= ( state >> 16 );
24 return state;
25 }
26
27 uint32_t mix32( uint32_t state, uint32_t extra ) { return mix( state + extra ); }
28
29 uint32_t mix64( uint32_t state, uint64_t extra )
30 {
31 typedef boost::low_bits_mask_t<32> mask_t;
32 state = mix32( state, uint32_t( extra & mask_t::sig_bits_fast ) );
33 return mix32( state, uint32_t( ( extra >> 32 ) & mask_t::sig_bits_fast ) );
34 }
35
36 uint32_t mixString( uint32_t state, const std::string& extra )
37 {
38 // prefix name with ' ' until the size is a multiple of 4.
39 std::string s = std::string( ( 4 - extra.size() % 4 ) % 4, ' ' ) + extra;
40 for ( size_t i = 0; i < s.size() / 4; ++i ) {
41 // FIXME: this might do something different on big endian vs. small endian machines...
42 uint32_t x = uint32_t( s[i * 4] ) | uint32_t( s[i * 4 + 1] ) << 8 | uint32_t( s[i * 4 + 2] ) << 16 |
43 uint32_t( s[i * 4 + 3] ) << 24;
44 state = mix32( state, x );
45 }
46 return state;
47 }
48 }
49 }
50 }
compareRootHistos.state
state
Definition: compareRootHistos.py:424
Gaudi::Utils::QuasiRandom::mixString
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:36
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:14
uint64_t
unsigned long long uint64_t
Definition: instrset.h:143
std::string
STL class.
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 &#39;extra&#39; entropy into &#39;state&#39; and return result
Definition: QuasiRandom.cpp:27
gaudirun.s
string s
Definition: gaudirun.py:253
QuasiRandom.h
Gaudi::Utils::QuasiRandom::mix64
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:29
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1