|
||||
File indexing completed on 2025-01-30 10:22:08
0001 // @(#)root/mathmore:$Id$ 0002 // Author: L. Moneta, A. Zsenei 08/2005 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT * 0007 * * 0008 * This library is free software; you can redistribute it and/or * 0009 * modify it under the terms of the GNU General Public License * 0010 * as published by the Free Software Foundation; either version 2 * 0011 * of the License, or (at your option) any later version. * 0012 * * 0013 * This library is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0016 * General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU General Public License * 0019 * along with this library (see file COPYING); if not, write * 0020 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 0021 * 330, Boston, MA 02111-1307 USA, or contact the author. * 0022 * * 0023 **********************************************************************/ 0024 0025 // Header file for class GSLRandom 0026 // 0027 // Created by: moneta at Sun Nov 21 16:26:03 2004 0028 // 0029 // Last update: Sun Nov 21 16:26:03 2004 0030 // 0031 #ifndef ROOT_Math_QuasiRandom 0032 #define ROOT_Math_QuasiRandom 0033 0034 #include <string> 0035 0036 /** 0037 @defgroup QuasiRandom QuasiRandom number generators and distributions 0038 Classes for generating QuasiRandom numbers and based on GSL 0039 @ingroup Random 0040 @ingroup MathMore 0041 */ 0042 0043 0044 0045 namespace ROOT { 0046 namespace Math { 0047 0048 0049 //_____________________________________________________________________________________ 0050 /** 0051 User class for MathMore random numbers template on the Engine type. 0052 The API of this class followed that of the class ROOT::Math::Random 0053 It must be implemented using as Engine one of the derived classes of 0054 ROOT::Math::GSLQuasiRandomEngine, like ROOT::Math::GSLQrngSobol 0055 0056 @ingroup QuasiRandom 0057 0058 */ 0059 template < class Engine> 0060 class QuasiRandom { 0061 0062 public: 0063 0064 0065 /** 0066 Create a QuasiRandom generator. Use default engine constructor. 0067 Engine will be initialized via Initialize() function in order to 0068 allocate resources 0069 */ 0070 QuasiRandom(unsigned int dimension = 1) { 0071 fEngine.Initialize(dimension); 0072 } 0073 0074 0075 /** 0076 Create a QuasiRandom generator based on a provided generic engine. 0077 Engine will be initialized via Initialize() function in order to 0078 allocate resources 0079 */ 0080 explicit QuasiRandom(const Engine & e, unsigned int dimension = 1) : fEngine(e) { 0081 fEngine.Initialize(dimension); 0082 } 0083 0084 /** 0085 Destructor: call Terminate() function of engine to free any 0086 allocated resource 0087 */ 0088 ~QuasiRandom() { 0089 fEngine.Terminate(); 0090 } 0091 0092 /** 0093 Generate next quasi random numbers points 0094 */ 0095 bool Next(double * x) { 0096 return fEngine(x); 0097 } 0098 0099 /** 0100 Generate next quasi random numbers point (1 - dimension) 0101 */ 0102 double Next() { 0103 return fEngine(); 0104 } 0105 0106 /** 0107 Generate quasi random numbers between ]0,1[ 0108 0 and 1 are excluded 0109 Function to be compatible with ROOT TRandom compatibility 0110 */ 0111 double Rndm() { 0112 return fEngine(); 0113 } 0114 0115 /** 0116 skip the next n number and jumb directly to the current state + n 0117 */ 0118 bool Skip(unsigned int n) { 0119 return fEngine.Skip(n); 0120 } 0121 /** 0122 Generate an array of random numbers between ]0,1[ 0123 Function to preserve ROOT Trandom compatibility 0124 The array will be filled as x1,y1,z1,....x2,y2,z2,... 0125 */ 0126 bool RndmArray(int n, double * array) { 0127 return fEngine.GenerateArray(array, array+n*NDim()); 0128 } 0129 0130 /** 0131 Return the type (name) of the used generator 0132 */ 0133 std::string Type() const { 0134 return fEngine.Name(); 0135 } 0136 0137 /** 0138 Return the size of the generator state 0139 */ 0140 unsigned int EngineSize() const { 0141 return fEngine.Size(); 0142 } 0143 0144 /** 0145 Return the dimension of the generator 0146 */ 0147 unsigned int NDim() const { 0148 return fEngine.NDim(); 0149 } 0150 0151 /** 0152 Return the name of the generator 0153 */ 0154 std::string Name() const { 0155 return fEngine.Name(); 0156 } 0157 0158 private: 0159 0160 Engine fEngine; 0161 0162 }; 0163 0164 0165 0166 } // namespace Math 0167 } // namespace ROOT 0168 0169 #include "Math/GSLQuasiRandom.h" 0170 0171 0172 0173 0174 namespace ROOT { 0175 namespace Math { 0176 0177 0178 typedef QuasiRandom<ROOT::Math::GSLQRngSobol> QuasiRandomSobol; 0179 typedef QuasiRandom<ROOT::Math::GSLQRngNiederreiter2> QuasiRandomNiederreiter; 0180 0181 } // namespace Math 0182 } // namespace ROOT 0183 0184 0185 #endif /* ROOT_Math_QuasiRandom */ 0186 0187 0188
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |