Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
QuasiRandom.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 GSLRandom
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_QuasiRandom
32#define ROOT_Math_QuasiRandom
33
34#include <string>
35
36/**
37 @defgroup QuasiRandom QuasiRandom number generators and distributions
38 Classes for generating QuasiRandom numbers and based on GSL.
39 \note MathMore needs to be enabled for these integrator to be available.
40 @ingroup Random
41*/
42
43namespace ROOT {
44namespace Math {
45
46
47//_____________________________________________________________________________________
48/**
49 User class for MathMore random numbers template on the Engine type.
50 The API of this class followed that of the class ROOT::Math::Random
51 It must be implemented using as Engine one of the derived classes of
52 ROOT::Math::GSLQuasiRandomEngine, like ROOT::Math::GSLQrngSobol
53
54 @ingroup QuasiRandom
55
56*/
57template < class Engine>
59
60public:
61
62
63 /**
64 Create a QuasiRandom generator. Use default engine constructor.
65 Engine will be initialized via Initialize() function in order to
66 allocate resources
67 */
68 QuasiRandom(unsigned int dimension = 1) {
69 fEngine.Initialize(dimension);
70 }
71
72
73 /**
74 Create a QuasiRandom generator based on a provided generic engine.
75 Engine will be initialized via Initialize() function in order to
76 allocate resources
77 */
78 explicit QuasiRandom(const Engine & e, unsigned int dimension = 1) : fEngine(e) {
79 fEngine.Initialize(dimension);
80 }
81
82 /**
83 Destructor: call Terminate() function of engine to free any
84 allocated resource
85 */
87 fEngine.Terminate();
88 }
89
90 /**
91 Generate next quasi random numbers points
92 */
93 bool Next(double * x) {
94 return fEngine(x);
95 }
96
97 /**
98 Generate next quasi random numbers point (1 - dimension)
99 */
100 double Next() {
101 return fEngine();
102 }
103
104 /**
105 Generate quasi random numbers between ]0,1[
106 0 and 1 are excluded
107 Function to be compatible with ROOT TRandom compatibility
108 */
109 double Rndm() {
110 return fEngine();
111 }
112
113 /**
114 skip the next n number and jumb directly to the current state + n
115 */
116 bool Skip(unsigned int n) {
117 return fEngine.Skip(n);
118 }
119 /**
120 Generate an array of random numbers between ]0,1[
121 Function to preserve ROOT Trandom compatibility
122 The array will be filled as x1,y1,z1,....x2,y2,z2,...
123 */
124 bool RndmArray(int n, double * array) {
125 return fEngine.GenerateArray(array, array+n*NDim());
126 }
127
128 /**
129 Return the type (name) of the used generator
130 */
131 std::string Type() const {
132 return fEngine.Name();
133 }
134
135 /**
136 Return the size of the generator state
137 */
138 unsigned int EngineSize() const {
139 return fEngine.Size();
140 }
141
142 /**
143 Return the dimension of the generator
144 */
145 unsigned int NDim() const {
146 return fEngine.NDim();
147 }
148
149 /**
150 Return the name of the generator
151 */
152 std::string Name() const {
153 return fEngine.Name();
154 }
155
156private:
157
158 Engine fEngine;
159
160};
161
162
163
164} // namespace Math
165} // namespace ROOT
166
167#include "Math/GSLQuasiRandom.h"
168
169
170
171
172namespace ROOT {
173namespace Math {
174
175
178
179} // namespace Math
180} // namespace ROOT
181
182
183#endif /* ROOT_Math_QuasiRandom */
184
185
186
#define e(i)
Definition RSha256.hxx:103
User class for MathMore random numbers template on the Engine type.
Definition QuasiRandom.h:58
QuasiRandom(unsigned int dimension=1)
Create a QuasiRandom generator.
Definition QuasiRandom.h:68
bool Next(double *x)
Generate next quasi random numbers points.
Definition QuasiRandom.h:93
bool Skip(unsigned int n)
skip the next n number and jumb directly to the current state + n
~QuasiRandom()
Destructor: call Terminate() function of engine to free any allocated resource.
Definition QuasiRandom.h:86
std::string Name() const
Return the name of the generator.
double Next()
Generate next quasi random numbers point (1 - dimension)
bool RndmArray(int n, double *array)
Generate an array of random numbers between ]0,1[ Function to preserve ROOT Trandom compatibility The...
double Rndm()
Generate quasi random numbers between ]0,1[ 0 and 1 are excluded Function to be compatible with ROOT ...
std::string Type() const
Return the type (name) of the used generator.
unsigned int EngineSize() const
Return the size of the generator state.
unsigned int NDim() const
Return the dimension of the generator.
QuasiRandom(const Engine &e, unsigned int dimension=1)
Create a QuasiRandom generator based on a provided generic engine.
Definition QuasiRandom.h:78
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for new Math classes and functions.
QuasiRandom< ROOT::Math::GSLQRngNiederreiter2 > QuasiRandomNiederreiter
QuasiRandom< ROOT::Math::GSLQRngSobol > QuasiRandomSobol