All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mcarlo.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2014, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_MCARLO_H
24 #define O2SCL_MCARLO_H
25 
26 /** \file mcarlo.h
27  \brief File defining \ref o2scl::mcarlo
28 */
29 
30 #include <iostream>
31 #include <random>
32 
33 #include <boost/numeric/ublas/vector.hpp>
34 
35 #include <o2scl/inte_multi.h>
36 #include <o2scl/rng_gsl.h>
37 
38 #ifndef DOXYGEN_NO_O2NS
39 namespace o2scl {
40 #endif
41 
42  /** \brief Monte-Carlo integration [abstract base]
43 
44  This class provides the generic Monte Carlo parameters and the
45  random number generator. The default type for the random number
46  generator is a \ref rng_gsl object.
47  */
48  template<class func_t=multi_funct11,
50  class rng_t=int, class rng_dist_t=rng_gsl>
51  //class rng_t=std::mt19937,
52  // class rng_dist_t=std::uniform_real_distribution<double> >
53  class mcarlo : public inte_multi<func_t,vec_t> {
54 
55  public:
56 
57  mcarlo() : rng_dist(0.0,1.0) {
58  n_points=1000;
59  }
60 
61  virtual ~mcarlo() {}
62 
63  /** \brief Number of integration points (default 1000)
64  */
65  unsigned long n_points;
66 
67  /// The random number distribution
68  rng_dist_t rng_dist;
69 
70  /// The random number generator
71  rng_t rng;
72 
73  /// Return string denoting type ("mcarlo")
74  virtual const char *type() { return "mcarlo"; }
75 
76  };
77 
78 #ifndef DOXYGEN_NO_O2NS
79 }
80 #endif
81 
82 #endif
83 
rng_dist_t rng_dist
The random number distribution.
Definition: mcarlo.h:68
unsigned long n_points
Number of integration points (default 1000)
Definition: mcarlo.h:65
rng_t rng
The random number generator.
Definition: mcarlo.h:71
Multi-dimensional integration over a hypercube [abstract base].
Definition: inte_multi.h:46
Monte-Carlo integration [abstract base].
Definition: mcarlo.h:53
virtual const char * type()
Return string denoting type ("mcarlo")
Definition: mcarlo.h:74
std::function< double(size_t, const boost::numeric::ublas::vector< double > &)> multi_funct11
Multi-dimensional function typedef.
Definition: multi_funct.h:45

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..