Changeset 3838 in Sophya for trunk/SophyaLib/BaseTools/randr48.cc


Ignore:
Timestamp:
Aug 9, 2010, 7:31:12 PM (15 years ago)
Author:
ansari
Message:

MAJ commentaires pour doxygen, passage methode Next() en pure virtual (=0), Reza 09/08/2010

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/randr48.cc

    r3739 r3838  
    1010namespace SOPHYA {
    1111
     12/*!
     13   \class DR48RandGen
     14   \ingroup BaseTools
     15   \brief  Implementation of the RandomGeneratorInterface class using drand48() functions
     16
     17   Its PPF handler can be used to save the complete state of the class and the underlying
     18   random number generator used.
     19
     20   \sa SOPHYA::ObjFileIO<ThSDR48RandGen>
     21
     22*/
     23
    1224static bool dr48_first = true;
    1325DR48RandGen::DR48RandGen()
     
    7082   \class ThSDR48RandGen
    7183   \ingroup BaseTools
    72    \brief Random number generator
    73 
    74    This class is a thread-safe random number generator.
     84   \brief Thread-safe version of DR48RandGen random number generator using drand48() functions.
     85
     86   
     87   Several instances of this class can be used in different threads without the risk of
     88   corrupting the internal state of the drand48() generator. However, in multi-thread applications,
     89   there is no guarantee to obtain the same sequence of numbers in each thread. 
    7590   Its PPF handler can be used to save the complete state of the class and the underlying
    76    random number generator used.
     91   random number generator (drand48() which is used.
    7792
    7893   \sa SOPHYA::ObjFileIO<ThSDR48RandGen>
    7994
     95   \code
     96   // A.1- Create a thread safe generator based on drand48()
     97   ThSDR48RandGen rg;
     98   // A.2- Auto initilize its state (using the system time)
     99   rg.AutoInit();
     100   // A.3- compute and print a smal sequence of random numbers
     101   int N = 10;
     102   for(int i=0; i<N; i++)
     103     cout << " I=" << i << "  rand_flat01= " << rg.Flat01() << " rand.gaussian= " << rg.Gaussian() << endl;
     104   // A.4- Save the generator state for subsequent use
     105   POutPersist po("rg.ppf");
     106   po << rg;
     107   // A.5- compute and print a second sequence of random numbers
     108   for(int i=0; i<N; i++)
     109     cout << "++ I=" << i+N << "  rand_flat01= " << rg.Flat01() << " rand.gaussian= " << rg.Gaussian() << endl;
     110   
     111   ...  In another program :
     112
     113   // B.1- Create and initialize the generator from the previously saved state
     114   ThSDR48RandGen rgr;
     115   PInPersist pin("rg.ppf");
     116   pin >> rgr;
     117   int N = 10;
     118   // B.2- Compute and print a sequence of random number, should be compared to the sequance A.5
     119   for(int i=0; i<N; i++)
     120     cout << "-- I=" << i << "  rand_flat01= " << rgr.Flat01() << " rand.gaussian= " << rgr.Gaussian() << endl;
     121   
     122   
     123   \endcode
    80124*/
    81125
    82126// Objet statique global pour gestion de lock entre threads
    83127static ThSafeOp* ths_rand = NULL;
     128
     129/*!
     130  \brief Constructor with optional specification of the internal buffer size and thread-safety flag
     131 
     132  The behaviour of the base class DR48RandGen can be reproduced by specifying tsafe=false
     133  \param n : an internal buffer of size n is created and filled through block calls to drand48()
     134  \param tsafe : if false, creates a non thread-safe generator
     135*/
    84136
    85137ThSDR48RandGen::ThSDR48RandGen(size_t n, bool tsafe)
Note: See TracChangeset for help on using the changeset viewer.