QMCPACK
RandomGenerator.h
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) 2022 QMCPACK developers.
6 //
7 // File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
10 // Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
11 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 /** @file RandomGenerator.h
18  * @brief Declare a global Random Number Generator
19  *
20  * Selected among
21  * - std::mt19937
22  * qmcplusplus::Random() returns a random number [0,1)
23  * For OpenMP is enabled, it is important to use thread-safe boost::random. Each
24  * thread uses its own random number generator with a distinct seed. This prevents
25  * a use of global lock which will slow down the applications significantly.
26  */
27 #ifndef OHMMS_RANDOMGENERATOR
28 #define OHMMS_RANDOMGENERATOR
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 #include <cstdint>
33 // The definition of the fake RNG should always be available for unit testing
34 #include "FakeRandom.h"
35 #include "StdRandom.h"
36 
37 uint32_t make_seed(int i, int n);
38 
39 namespace qmcplusplus
40 {
41 template<class RNG>
42 class RNGThreadSafe : public RNG
43 {
44 public:
45  using result_type = typename RNG::result_type;
46 
47  /** return a random number [0,1)
48  */
49  result_type operator()() override;
50 };
51 
54 
57 #define Random random_global
58 } // namespace qmcplusplus
59 
60 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
RNGThreadSafe< RandomGenerator > random_global
uint32_t make_seed(int i, int n)
result_type operator()() override
return a random number [0,1)
A minimally functional wrapper for the since c++11 <random>
typename RNG::result_type result_type