ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
random.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2011-2013 by Michele Dolfi <dolfim@phys.ethz.ch>
7  *
8  * This software is part of the ALPS Applications, published under the ALPS
9  * Application License; you can use, redistribute it and/or modify it under
10  * the terms of the license, either version 1 or (at your option) any later
11  * version.
12  *
13  * You should have received a copy of the ALPS Application License along with
14  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15  * available from http://alps.comp-phys.org/.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  *****************************************************************************/
26 
27 #ifndef UTILS_DMRG_RANDOM_HPP
28 #define UTILS_DMRG_RANDOM_HPP
29 
30 #include <boost/random.hpp>
31 
32 struct dmrg_random {
33  typedef double value_type;
34  typedef boost::mt19937 engine_t;
35  typedef boost::uniform_real<value_type> uniform_dist_t;
36  typedef boost::normal_distribution<value_type> normal_dist_t;
37  typedef boost::poisson_distribution<value_type> poisson_dist_t;
38 
39  static engine_t engine;
40 
41  // Uniform distribution
42  static inline value_type uniform (value_type min, value_type max) {
43  uniform_dist_t dist(min, max);
44  return dist(engine);
45  }
46 
47  static inline value_type uniform () {
48  return uniform(0, 1);
49  }
50 
51 
52  // Normal distribution
53  static inline value_type normal (value_type mean, value_type sigma) {
54  normal_dist_t dist(mean, sigma);
55  return dist(engine);
56  }
57 
58  static inline value_type normal () {
59  return normal(0, 1);
60  }
61 
62 
63  // Poisson distribution
64  /*
65  static inline value_type poisson (value_type mean) {
66  poisson_dist_t dist(mean);
67  return dist(engine);
68  }
69 
70  static inline value_type poisson () {
71  return poisson(1);
72  }
73 */
74 
75 };
76 
77 #endif
static engine_t engine
Definition: random.hpp:39
boost::poisson_distribution< value_type > poisson_dist_t
Definition: random.hpp:37
boost::normal_distribution< value_type > normal_dist_t
Definition: random.hpp:36
double value_type
Definition: random.hpp:33
boost::mt19937 engine_t
Definition: random.hpp:34
boost::uniform_real< value_type > uniform_dist_t
Definition: random.hpp:35
static value_type uniform()
Definition: random.hpp:47
static value_type normal()
Definition: random.hpp:58
static value_type normal(value_type mean, value_type sigma)
Definition: random.hpp:53
static value_type uniform(value_type min, value_type max)
Definition: random.hpp:42