Logo ROOT   6.08/07
Reference Guide
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 #include <vector>
36 
37 namespace ROOT {
38 namespace Math {
39 
40 
41  class GSLQRngWrapper;
42 
43  //_________________________________________________________________
44  /**
45  GSLQuasiRandomEngine
46  Base class for all GSL quasi random engines,
47  normally user instantiate the derived classes
48  which creates internally the generator and uses the class ROOT::Math::QuasiRandom
49 
50 
51  @ingroup Random
52  */
54 
55  public:
56 
57  /**
58  default constructor. No creation of rng is done.
59  If then Initialize() is called an engine is created
60  based on default GSL type (MT)
61  */
63 
64  /**
65  create from an existing rng.
66  User manage the rng pointer which is then deleted olny by calling Terminate()
67  */
69 
70  /**
71  Copy constructor : clone the contained GSL generator
72  */
74 
75  /**
76  Assignment operator : make a deep copy of the contained GSL generator
77  */
79 
80  /**
81  initialize the generator giving the dimension of the sequence
82  If no rng is present the default one based on Mersenne and Twister is created
83  */
84  void Initialize(unsigned int dimension);
85 
86  /**
87  delete pointer to contained rng
88  */
89  void Terminate();
90 
91  /**
92  call Terminate()
93  */
94  virtual ~GSLQuasiRandomEngine();
95 
96  /**
97  Generate a random number between ]0,1[
98  */
99  double operator() () const;
100 
101  /**
102  Fill array x with random numbers between ]0,1[
103  */
104  bool operator() (double * x) const;
105 
106  /**
107  Skip the next n random numbers
108  */
109  bool Skip(unsigned int n) const;
110 
111  /**
112  Generate an array of quasi random numbers
113  The iterators points to the random numbers
114  */
115  bool GenerateArray(double * begin, double * end) const;
116 
117  /**
118  return name of generator
119  */
120  std::string Name() const;
121 
122  /**
123  return the state size of generator
124  */
125  unsigned int Size() const;
126 
127  /**
128  return the dimension of generator
129  */
130  unsigned int NDim() const;
131 
132 
133 
134  protected:
135 
136  /// internal method used by the derived class to set the type of generators
138  fQRng = r;
139  }
140 
141  private:
142 
143  GSLQRngWrapper * fQRng; // pointer to GSL generator wrapper (managed by the class)
144 
145 
146  };
147 
148  //_____________________________________________________________________________________
149  /**
150  Sobol generator
151  gsl_qrng_sobol from
152  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>
153 
154 
155  @ingroup Random
156  */
158  public:
159  GSLQRngSobol();
160  };
161 
162  //_____________________________________________________________________________________
163  /**
164  Niederreiter generator
165  gsl_qrng_niederreiter_2 from
166  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>
167 
168  @ingroup Random
169  */
171  public:
173  };
174 
175 
176 
177 
178 } // namespace Math
179 } // namespace ROOT
180 
181 
182 #endif /* ROOT_Math_GSLQuasiRandom */
183 
unsigned int NDim() const
return the dimension of generator
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
GSLQuasiRandomEngine & operator=(const GSLQuasiRandomEngine &eng)
Assignment operator : make a deep copy of the contained GSL generator.
void SetType(GSLQRngWrapper *r)
internal method used by the derived class to set the type of generators
bool GenerateArray(double *begin, double *end) const
Generate an array of quasi random numbers The iterators points to the random numbers.
Double_t x[n]
Definition: legend1.C:17
void Initialize(unsigned int dimension)
initialize the generator giving the dimension of the sequence If no rng is present the default one ba...
unsigned int Size() const
return the state size of generator
virtual ~GSLQuasiRandomEngine()
call Terminate()
std::string Name() const
return name of generator
TRandom2 r(17)
Niederreiter generator gsl_qrng_niederreiter_2 from here
bool Skip(unsigned int n) const
Skip the next n random numbers.
void Terminate()
delete pointer to contained rng
Namespace for new Math classes and functions.
GSLQRngWrapper class to wrap gsl_qrng structure.
Sobol generator gsl_qrng_sobol from here
GSLQuasiRandomEngine Base class for all GSL quasi random engines, normally user instantiate the deriv...
GSLQuasiRandomEngine()
default constructor.
double operator()() const
Generate a random number between ]0,1[.
const Int_t n
Definition: legend1.C:16