Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:28

0001 #ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
0002 #define BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED
0003 
0004 // Copyright 2020 Peter Dimov
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // https://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // An implementation of splitmix64 for testing purposes,
0009 // derived from Sebastiano Vigna's public domain implementation
0010 // http://xorshift.di.unimi.it/splitmix64.c
0011 
0012 #include <boost/cstdint.hpp>
0013 
0014 namespace boost
0015 {
0016 namespace detail
0017 {
0018 
0019 class splitmix64
0020 {
0021 private:
0022 
0023     boost::uint64_t x_;
0024 
0025 public:
0026 
0027     splitmix64(): x_( 0 )
0028     {
0029     }
0030 
0031     explicit splitmix64( boost::uint64_t seed ): x_( seed )
0032     {
0033     }
0034 
0035     boost::uint64_t operator()()
0036     {
0037         x_ += ( boost::uint64_t(0x9e3779b9u) << 32 ) + 0x7f4a7c15u;
0038 
0039         boost::uint64_t z = x_;
0040 
0041         z ^= z >> 30;
0042         z *= ( boost::uint64_t(0xbf58476du) << 32 ) + 0x1ce4e5b9u;
0043         z ^= z >> 27;
0044         z *= ( boost::uint64_t(0x94d049bbu) << 32 ) + 0x133111ebu;
0045         z ^= z >> 31;
0046 
0047         return z;
0048     }
0049 };
0050 
0051 } // namespace detail
0052 } // namespace boost
0053 
0054 #endif // #ifndef BOOST_CORE_DETAIL_SPLITMIX64_HPP_INCLUDED