| The Gaudi Framework v28r2-patches (bc4ad17a)

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