// @(#)root/mathmore:$Id$
// Author: L. Moneta, A. Zsenei   08/2005

 /**********************************************************************
  *                                                                    *
  * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
  *                                                                    *
  * This library is free software; you can redistribute it and/or      *
  * modify it under the terms of the GNU General Public License        *
  * as published by the Free Software Foundation; either version 2     *
  * of the License, or (at your option) any later version.             *
  *                                                                    *
  * This library is distributed in the hope that it will be useful,    *
  * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
  * General Public License for more details.                           *
  *                                                                    *
  * You should have received a copy of the GNU General Public License  *
  * along with this library (see file COPYING); if not, write          *
  * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
  * 330, Boston, MA 02111-1307 USA, or contact the author.             *
  *                                                                    *
  **********************************************************************/

// Header file for class GSLQuasiRandom
//
// Created by: moneta  at Sun Nov 21 16:26:03 2004
//
// Last update: Sun Nov 21 16:26:03 2004
//
#ifndef ROOT_Math_GSLQuasiRandom
#define ROOT_Math_GSLQuasiRandom

#include <string>
#include <vector>

namespace ROOT {
namespace Math {


   class GSLQRngWrapper;

   //_________________________________________________________________
   /**
      GSLQuasiRandomEngine
      Base class for all GSL quasi random engines,
      normally user instantiate the derived classes
      which creates internally the generator and uses the class ROOT::Math::QuasiRandom


      @ingroup Random
   */
   class GSLQuasiRandomEngine {

   public:

     /**
         default constructor. No creation of rng is done.
         If then Initialize() is called an engine is created
         based on default GSL type (MT)
     */
      GSLQuasiRandomEngine();

      /**
          create from an existing rng.
          User manage the rng pointer which is then deleted olny by calling Terminate()
      */
      GSLQuasiRandomEngine( GSLQRngWrapper * rng);

      /**
         Copy constructor : clone the contained GSL generator
       */
      GSLQuasiRandomEngine(const GSLQuasiRandomEngine & eng);

      /**
         Assignment operator : make a deep copy of the contained GSL generator
       */
      GSLQuasiRandomEngine & operator=(const GSLQuasiRandomEngine & eng);

      /**
         initialize the generator giving the dimension of the sequence
         If no rng is present the default one based on Mersenne and Twister is created
       */
      void Initialize(unsigned int dimension);

      /**
         delete pointer to contained rng
       */
      void Terminate();

      /**
         call Terminate()
      */
      virtual ~GSLQuasiRandomEngine();

      /**
         Generate a  random number between ]0,1[
      */
      double operator() () const;

      /**
         Fill array x with random numbers between ]0,1[
      */
      bool operator() (double * x) const;

      /**
         Skip the next n random numbers
       */
      bool Skip(unsigned int n) const;

      /**
         Generate an array of quasi random numbers
         The iterators points to the random numbers
      */
      bool GenerateArray(double * begin, double * end) const;

      /**
         return name of generator
      */
      std::string Name() const;

      /**
         return the state size of generator
      */
      unsigned int Size() const;

      /**
         return the dimension of generator
      */
      unsigned int NDim() const;



   protected:

      /// internal method used by the derived class to set the type of generators
      void SetType(GSLQRngWrapper * r) {
         fQRng = r;
      }

   private:

      GSLQRngWrapper * fQRng;                // pointer to GSL generator wrapper (managed by the class)


   };

   //_____________________________________________________________________________________
   /**
      Sobol generator
      gsl_qrng_sobol from
      <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>


      @ingroup Random
   */
   class GSLQRngSobol : public GSLQuasiRandomEngine {
   public:
      GSLQRngSobol();
   };

   //_____________________________________________________________________________________
   /**
      Niederreiter generator
      gsl_qrng_niederreiter_2 from
      <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Quasi_002drandom-number-generator-algorithms.html#Quasi_002drandom-number-generator-algorithms">here</A>

      @ingroup Random
   */
   class GSLQRngNiederreiter2 : public GSLQuasiRandomEngine {
   public:
      GSLQRngNiederreiter2();
   };




} // namespace Math
} // namespace ROOT


#endif /* ROOT_Math_GSLQuasiRandom */

 GSLQuasiRandom.h:1
 GSLQuasiRandom.h:2
 GSLQuasiRandom.h:3
 GSLQuasiRandom.h:4
 GSLQuasiRandom.h:5
 GSLQuasiRandom.h:6
 GSLQuasiRandom.h:7
 GSLQuasiRandom.h:8
 GSLQuasiRandom.h:9
 GSLQuasiRandom.h:10
 GSLQuasiRandom.h:11
 GSLQuasiRandom.h:12
 GSLQuasiRandom.h:13
 GSLQuasiRandom.h:14
 GSLQuasiRandom.h:15
 GSLQuasiRandom.h:16
 GSLQuasiRandom.h:17
 GSLQuasiRandom.h:18
 GSLQuasiRandom.h:19
 GSLQuasiRandom.h:20
 GSLQuasiRandom.h:21
 GSLQuasiRandom.h:22
 GSLQuasiRandom.h:23
 GSLQuasiRandom.h:24
 GSLQuasiRandom.h:25
 GSLQuasiRandom.h:26
 GSLQuasiRandom.h:27
 GSLQuasiRandom.h:28
 GSLQuasiRandom.h:29
 GSLQuasiRandom.h:30
 GSLQuasiRandom.h:31
 GSLQuasiRandom.h:32
 GSLQuasiRandom.h:33
 GSLQuasiRandom.h:34
 GSLQuasiRandom.h:35
 GSLQuasiRandom.h:36
 GSLQuasiRandom.h:37
 GSLQuasiRandom.h:38
 GSLQuasiRandom.h:39
 GSLQuasiRandom.h:40
 GSLQuasiRandom.h:41
 GSLQuasiRandom.h:42
 GSLQuasiRandom.h:43
 GSLQuasiRandom.h:44
 GSLQuasiRandom.h:45
 GSLQuasiRandom.h:46
 GSLQuasiRandom.h:47
 GSLQuasiRandom.h:48
 GSLQuasiRandom.h:49
 GSLQuasiRandom.h:50
 GSLQuasiRandom.h:51
 GSLQuasiRandom.h:52
 GSLQuasiRandom.h:53
 GSLQuasiRandom.h:54
 GSLQuasiRandom.h:55
 GSLQuasiRandom.h:56
 GSLQuasiRandom.h:57
 GSLQuasiRandom.h:58
 GSLQuasiRandom.h:59
 GSLQuasiRandom.h:60
 GSLQuasiRandom.h:61
 GSLQuasiRandom.h:62
 GSLQuasiRandom.h:63
 GSLQuasiRandom.h:64
 GSLQuasiRandom.h:65
 GSLQuasiRandom.h:66
 GSLQuasiRandom.h:67
 GSLQuasiRandom.h:68
 GSLQuasiRandom.h:69
 GSLQuasiRandom.h:70
 GSLQuasiRandom.h:71
 GSLQuasiRandom.h:72
 GSLQuasiRandom.h:73
 GSLQuasiRandom.h:74
 GSLQuasiRandom.h:75
 GSLQuasiRandom.h:76
 GSLQuasiRandom.h:77
 GSLQuasiRandom.h:78
 GSLQuasiRandom.h:79
 GSLQuasiRandom.h:80
 GSLQuasiRandom.h:81
 GSLQuasiRandom.h:82
 GSLQuasiRandom.h:83
 GSLQuasiRandom.h:84
 GSLQuasiRandom.h:85
 GSLQuasiRandom.h:86
 GSLQuasiRandom.h:87
 GSLQuasiRandom.h:88
 GSLQuasiRandom.h:89
 GSLQuasiRandom.h:90
 GSLQuasiRandom.h:91
 GSLQuasiRandom.h:92
 GSLQuasiRandom.h:93
 GSLQuasiRandom.h:94
 GSLQuasiRandom.h:95
 GSLQuasiRandom.h:96
 GSLQuasiRandom.h:97
 GSLQuasiRandom.h:98
 GSLQuasiRandom.h:99
 GSLQuasiRandom.h:100
 GSLQuasiRandom.h:101
 GSLQuasiRandom.h:102
 GSLQuasiRandom.h:103
 GSLQuasiRandom.h:104
 GSLQuasiRandom.h:105
 GSLQuasiRandom.h:106
 GSLQuasiRandom.h:107
 GSLQuasiRandom.h:108
 GSLQuasiRandom.h:109
 GSLQuasiRandom.h:110
 GSLQuasiRandom.h:111
 GSLQuasiRandom.h:112
 GSLQuasiRandom.h:113
 GSLQuasiRandom.h:114
 GSLQuasiRandom.h:115
 GSLQuasiRandom.h:116
 GSLQuasiRandom.h:117
 GSLQuasiRandom.h:118
 GSLQuasiRandom.h:119
 GSLQuasiRandom.h:120
 GSLQuasiRandom.h:121
 GSLQuasiRandom.h:122
 GSLQuasiRandom.h:123
 GSLQuasiRandom.h:124
 GSLQuasiRandom.h:125
 GSLQuasiRandom.h:126
 GSLQuasiRandom.h:127
 GSLQuasiRandom.h:128
 GSLQuasiRandom.h:129
 GSLQuasiRandom.h:130
 GSLQuasiRandom.h:131
 GSLQuasiRandom.h:132
 GSLQuasiRandom.h:133
 GSLQuasiRandom.h:134
 GSLQuasiRandom.h:135
 GSLQuasiRandom.h:136
 GSLQuasiRandom.h:137
 GSLQuasiRandom.h:138
 GSLQuasiRandom.h:139
 GSLQuasiRandom.h:140
 GSLQuasiRandom.h:141
 GSLQuasiRandom.h:142
 GSLQuasiRandom.h:143
 GSLQuasiRandom.h:144
 GSLQuasiRandom.h:145
 GSLQuasiRandom.h:146
 GSLQuasiRandom.h:147
 GSLQuasiRandom.h:148
 GSLQuasiRandom.h:149
 GSLQuasiRandom.h:150
 GSLQuasiRandom.h:151
 GSLQuasiRandom.h:152
 GSLQuasiRandom.h:153
 GSLQuasiRandom.h:154
 GSLQuasiRandom.h:155
 GSLQuasiRandom.h:156
 GSLQuasiRandom.h:157
 GSLQuasiRandom.h:158
 GSLQuasiRandom.h:159
 GSLQuasiRandom.h:160
 GSLQuasiRandom.h:161
 GSLQuasiRandom.h:162
 GSLQuasiRandom.h:163
 GSLQuasiRandom.h:164
 GSLQuasiRandom.h:165
 GSLQuasiRandom.h:166
 GSLQuasiRandom.h:167
 GSLQuasiRandom.h:168
 GSLQuasiRandom.h:169
 GSLQuasiRandom.h:170
 GSLQuasiRandom.h:171
 GSLQuasiRandom.h:172
 GSLQuasiRandom.h:173
 GSLQuasiRandom.h:174
 GSLQuasiRandom.h:175
 GSLQuasiRandom.h:176
 GSLQuasiRandom.h:177
 GSLQuasiRandom.h:178
 GSLQuasiRandom.h:179
 GSLQuasiRandom.h:180
 GSLQuasiRandom.h:181
 GSLQuasiRandom.h:182
 GSLQuasiRandom.h:183