CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
SplitMix.hpp
1 /*
2  * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 /*
10  * SplitMix.hpp
11  *
12  * Created on: 25/02/2021
13  * Author: Antonio Augusto Alves Junior
14  */
15 
16 #pragma once
17 
18 namespace random_iterator {
19 
20  namespace detail {
21 
22  template <typename UIntType>
23  inline UIntType splitmix(UIntType&);
24 
25  template <>
26  inline uint32_t splitmix<uint32_t>(uint32_t& x) {
27  uint32_t z = (x += 0x6D2B79F5UL);
28  z = (z ^ (z >> 15)) * (z | 1UL);
29  z ^= z + (z ^ (z >> 7)) * (z | 61UL);
30  return z ^ (z >> 14);
31  }
32 
33  template <>
34  inline uint64_t splitmix<uint64_t>(uint64_t& x) {
35  uint64_t z = (x += 0x9e3779b97f4a7c15);
36  z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
37  z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
38  return z ^ (z >> 31);
39  }
40 
41  } // namespace detail
42 
43 } // namespace random_iterator