Bayeux  3.4.1
Core Foundation library for SuperNEMO
von_neumann_method.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2009-09-23
4  * Last modified: 2009-09-23
5  *
6  * License:
7  *
8  *
9  * Description:
10  *
11  * A Von Neumann Pseudo Random Number generator
12  * for an arbitrary R to R functor used as the density function.
13  *
14  * History:
15  *
16  */
17 
18 #ifndef MYGSL_VON_NEUMANN_METHOD_H
19 #define MYGSL_VON_NEUMANN_METHOD_H 1
20 
21 // Standard library:
22 #include <iostream>
23 
24 // This project:
25 #include <mygsl/rng.h>
26 #include <mygsl/i_unary_function.h>
27 
28 namespace mygsl {
29 
32  {
33  public:
34 
35  static const double AUTO_FMAX;
36  static const size_t MIN_NSAMPLES = 2;
37  static const size_t DEFAULT_NSAMPLES = 1000;
38  static const size_t DEFAULT_MAX_COUNTS = 10000;
39  static const size_t NO_MAX_COUNTS = 0;
40 
41  bool is_initialized() const;
42 
43  double get_xmin() const;
44 
45  double get_xmax() const;
46 
47  double get_fmax() const;
48 
49  size_t get_max_counts() const;
50 
52 
53  von_neumann_method(double xmin_,
54  double xmax_,
55  const i_unary_function & func_,
56  double fmax_ = 0.0,
57  size_t nsamples_ = DEFAULT_NSAMPLES,
58  size_t max_counts_ = DEFAULT_MAX_COUNTS);
59 
60  void initialize(double xmin_,
61  double xmax_,
62  const i_unary_function & func_,
63  double fmax_,
64  size_t nsamples_,
65  size_t max_counts_);
66 
68  void init(double xmin_,
69  double xmax_,
70  const i_unary_function & func_,
71  double fmax_,
72  size_t nsamples_ = DEFAULT_NSAMPLES,
73  size_t max_counts_ = DEFAULT_MAX_COUNTS);
74 
75  void reset();
76 
77  double shoot(rng &);
78 
79  void dump(std::ostream & out_ = std::clog) const;
80 
81  private:
82 
83  double _xmin_;
84  double _xmax_;
85  double _fmax_;
86  const i_unary_function * _func_;
87  size_t _max_counts_;
88 
89  };
90 
91 } // end of namespace mygsl
92 
93 #endif // MYGSL_VON_NEUMANN_METHOD_H
94 
95 /* Local Variables: */
96 /* mode: c++ */
97 /* coding: utf-8 */
98 /* End: */
static const size_t MIN_NSAMPLES
Definition: von_neumann_method.h:36
static const double AUTO_FMAX
Definition: von_neumann_method.h:35
static const size_t DEFAULT_NSAMPLES
Definition: von_neumann_method.h:37
size_t get_max_counts() const
static const size_t NO_MAX_COUNTS
Definition: von_neumann_method.h:39
static const size_t DEFAULT_MAX_COUNTS
Definition: von_neumann_method.h:38
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
void initialize(double xmin_, double xmax_, const i_unary_function &func_, double fmax_, size_t nsamples_, size_t max_counts_)
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
void dump(std::ostream &out_=std::clog) const
Von Neumann's rejection method for one dimensional PDF.
Definition: von_neumann_method.h:31
void init(double xmin_, double xmax_, const i_unary_function &func_, double fmax_, size_t nsamples_=DEFAULT_NSAMPLES, size_t max_counts_=DEFAULT_MAX_COUNTS)
Pseudo random number generator.
Definition: rng.h:53