Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
GSLQuasiRandom.h
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Author: L. Moneta, A. Zsenei 08/2005
3 
4  /**********************************************************************
5  * *
6  * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License *
10  * as published by the Free Software Foundation; either version 2 *
11  * of the License, or (at your option) any later version. *
12  * *
13  * This library 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 GNU *
16  * General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this library (see file COPYING); if not, write *
20  * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21  * 330, Boston, MA 02111-1307 USA, or contact the author. *
22  * *
23  **********************************************************************/
24 
25 // Header file for class GSLQuasiRandom
26 //
27 // Created by: moneta at Sun Nov 21 16:26:03 2004
28 //
29 // Last update: Sun Nov 21 16:26:03 2004
30 //
31 #ifndef ROOT_Math_GSLQuasiRandom
32 #define ROOT_Math_GSLQuasiRandom
33 
34 #include <string>
35 
36 namespace ROOT {
37 namespace Math {
38 
39 
40  class GSLQRngWrapper;
41 
42  //_________________________________________________________________
43  /**
44  GSLQuasiRandomEngine
45  Base class for all GSL quasi random engines,
46  normally user instantiate the derived classes
47  which creates internally the generator and uses the class ROOT::Math::QuasiRandom
48 
49 
50  @ingroup Random
51  */
52  class GSLQuasiRandomEngine {
53 
54  public:
55 
56  /**
57  default constructor. No creation of rng is done.
58  If then Initialize() is called an engine is created
59  based on default GSL type (MT)
60  */
61  GSLQuasiRandomEngine();
62 
63  /**
64  create from an existing rng.
65  User manage the rng pointer which is then deleted olny by calling Terminate()
66  */
67  GSLQuasiRandomEngine( GSLQRngWrapper * rng);
68 
69  /**
70  Copy constructor : clone the contained GSL generator
71  */
72  GSLQuasiRandomEngine(const GSLQuasiRandomEngine & eng);
73 
74  /**
75  Assignment operator : make a deep copy of the contained GSL generator
76  */
77  GSLQuasiRandomEngine & operator=(const GSLQuasiRandomEngine & eng);
78 
79  /**
80  initialize the generator giving the dimension of the sequence
81  If no rng is present the default one based on Mersenne and Twister is created
82  */
83  void Initialize(unsigned int dimension);
84 
85  /**
86  delete pointer to contained rng
87  */
88  void Terminate();
89 
90  /**
91  call Terminate()
92  */
93  virtual ~GSLQuasiRandomEngine();
94 
95  /**
96  Generate a random number between ]0,1[
97  */
98  double operator() () const;
99 
100  /**
101  Fill array x with random numbers between ]0,1[
102  */
103  bool operator() (double * x) const;
104 
105  /**
106  Skip the next n random numbers
107  */
108  bool Skip(unsigned int n) const;
109 
110  /**
111  Generate an array of quasi random numbers
112  The iterators points to the random numbers
113  */
114  bool GenerateArray(double * begin, double * end) const;
115 
116  /**
117  return name of generator
118  */
119  std::string Name() const;
120 
121  /**
122  return the state size of generator
123  */
124  unsigned int Size() const;
125 
126  /**
127  return the dimension of generator
128  */
129  unsigned int NDim() const;
130 
131 
132 
133  protected:
134 
135  /// internal method used by the derived class to set the type of generators
136  void SetType(GSLQRngWrapper * r) {
137  fQRng = r;
138  }
139 
140  private:
141 
142  GSLQRngWrapper * fQRng; // pointer to GSL generator wrapper (managed by the class)
143 
144 
145  };
146 
147  //_____________________________________________________________________________________
148  /**
149  Sobol generator
150  gsl_qrng_sobol from
151  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>
152 
153 
154  @ingroup Random
155  */
156  class GSLQRngSobol : public GSLQuasiRandomEngine {
157  public:
158  GSLQRngSobol();
159  };
160 
161  //_____________________________________________________________________________________
162  /**
163  Niederreiter generator
164  gsl_qrng_niederreiter_2 from
165  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>
166 
167  @ingroup Random
168  */
169  class GSLQRngNiederreiter2 : public GSLQuasiRandomEngine {
170  public:
171  GSLQRngNiederreiter2();
172  };
173 
174 
175 
176 
177 } // namespace Math
178 } // namespace ROOT
179 
180 
181 #endif /* ROOT_Math_GSLQuasiRandom */
182