QMCPACK
RandomGenerator.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #include "RandomGenerator.h"
15 #include <ctime>
16 
17 uint32_t make_seed(int i, int n) { return static_cast<uint32_t>(std::time(0)) % 10474949 + (i + 1) * n + i; }
18 
19 namespace qmcplusplus
20 {
21 
22 template<class RNG>
23 typename RNG::result_type RNGThreadSafe<RNG>::operator()()
24 {
25  result_type result;
26 #pragma omp critical
27  {
28  result = RNG::operator()();
29  }
30  return result;
31 }
32 
34 template class RNGThreadSafe<RandomGenerator>;
35 
38 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
RNGThreadSafe< FakeRandom< OHMMS_PRECISION_FULL > > fake_random_global
RNGThreadSafe< RandomGenerator > random_global
result_type operator()() override
return a random number [0,1)
typename RNG::result_type result_type
uint32_t make_seed(int i, int n)
Declare a global Random Number Generator.