Logo ROOT   6.21/01
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 
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  */
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  */
62 
63  /**
64  create from an existing rng.
65  User manage the rng pointer which is then deleted olny by calling Terminate()
66  */
68 
69  /**
70  Copy constructor : clone the contained GSL generator
71  */
73 
74  /**
75  Assignment operator : make a deep copy of the contained GSL generator
76  */
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
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  */
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  */
170  public:
172  };
173 
174 
175 
176 
177 } // namespace Math
178 } // namespace ROOT
179 
180 
181 #endif /* ROOT_Math_GSLQuasiRandom */
182 
unsigned int NDim() const
return the dimension of generator
Returns the available number of logical cores.
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
ROOT::R::TRInterface & r
Definition: Object.C:4
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