Changeset 3838 in Sophya for trunk/SophyaLib


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

Location:
trunk/SophyaLib
Files:
5 edited

Legend:

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

    r3791 r3838  
    77#include <time.h>
    88#include <iostream>
     9#include <typeinfo>
     10
    911#include "pexceptions.h"
    1012
     
    6567void RandomGeneratorInterface::ShowRandom()
    6668{
    67   cout<<"RandomGenerator is RandomGeneratorInterface i.e. UNDEFINED"<<endl;
    68 }
    69 
    70 /////////////////////////////////////////////////////////////////////////
    71 /////////////////////////////////////////////////////////////////////////
    72 /////////////////////////////////////////////////////////////////////////
    73 
     69  cout << " RandomGeneratorInterface::ShowRandom() typeid(this)=" << typeid(*this).name() << " @ "
     70       << hex << (unsigned long)(this) << dec << endl;
     71  return;
     72}
     73
     74/////////////////////////////////////////////////////////////////////////
     75/////////////////////////////////////////////////////////////////////////
     76/////////////////////////////////////////////////////////////////////////
     77
     78/*
    7479r_8 RandomGeneratorInterface::Next()
    7580{
     
    7782  throw MathExc("RandomGeneratorInterface::Next(): undefined code !!!");
    7883}
     84*/
    7985
    8086/////////////////////////////////////////////////////////////////////////
  • trunk/SophyaLib/BaseTools/randinterf.h

    r3615 r3838  
    137137
    138138protected:
    139   //! Return a random number in [0,1]
    140   virtual r_8 Next();
     139  /*! \brief Should return a random number in the range [0,1] with flat distribution
     140
     141     This pure virtual method should be implemented by inheriting classes  */
     142  virtual r_8 Next() = 0;
    141143
    142144// Selection de type d'algo pour les aleatoires autres que plates
  • 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)
  • trunk/SophyaLib/BaseTools/randr48.h

    r3739 r3838  
    1515
    1616
    17 /* ------- SPECIFIQUE Mac Darwin OSX  <= 10.2 (gcc < 3.x) -------- */
    18 #if defined(Darwin) &&  defined(__GNUC__) && (__GNUC__ < 3)
    19 #include "osx_values.h"
    20 /* Declaration de drand48 et srand48 etc , mis ds SysSpec, Reza 11/02/2003 */
    21 #ifdef __cplusplus
    22 extern "C" {
    23 #endif
    24 unsigned short int * seed48(unsigned short int seed16v[3]);
    25 void srand48(long seedval);
    26 #ifdef __cplusplus
    27 }
    28 #endif
    29 #define drand48() ((double)(random())/LONG_MAX)
    30 #endif
    31 /* ------- FIN SPECIFIQUE Mac OSX / Darwin V <= 10.2 --------- */
    32 
    33 
    3417namespace SOPHYA {
    3518
    36 //! Implementation of the RandomGeneratorInterface class using drand48() functions
     19// Implementation de RandomGeneratorInterface avec drand48()
    3720class DR48RandGen : public RandomGeneratorInterface {
    3821
     
    6043//--------------------------------------------------------------------------------
    6144
    62 //! Version thread-safe de RandomGeneratorInterface avec drand48() functions
     45// Version thread-safe de  DR48RandGen
    6346class ThSDR48RandGen : public DR48RandGen {
    6447
  • trunk/SophyaLib/TArray/spesqmtx.cc

    r3831 r3838  
    99#include "tmatrix.h"
    1010
    11 // doit etre mis en dehors du namespace
     11namespace SOPHYA {
    1212/*!
    13   \class SOPHYA::SpecialSquareMatrix
     13  \class SpecialSquareMatrix
    1414  \ingroup TArray
    1515  \brief The base class for representing and manipulating special square matrices
    1616  Diagonal matrix, Symmetric matrix, Triangular matrix
    17 
    1817  This class implements the common operations for special square matrices. Only objects
     18
    1919  from the sub-classes (DiagonalMatrix<T>, LowerTriangularMatrix<T>, SymmetricMatrix<T>)
    2020  can be instanciated. Theses classes offer similar functionalities to the TArray<T> / TMatrix<T>
    2121  classes, like reference sharing and arithmetic operations. However, no sub-matrix extraction
    2222  method is provided.
    23   sub matrix extraction method.
     23
     24  \code
     25  // Create and initialize a diagonal matrix
     26  DiagonalMatrix<double> diag(3);
     27  diag(0,0)=1.;  diag(1,1)=2.;  diag(2,2)=3.;
     28  // use of multiplication by a constant operator
     29  diag *= 10.;
     30  // check the diagonal matrix
     31  cout << diag << diag.ConvertToStdMatrix() << endl;
     32  // define and initialize a general matrix
     33  TMatrix<double> mx(3,3);
     34  mx=RegularSequence();
     35  cout << mx;
     36  // check the result of a matrix mutiplication
     37  cout << mx*diag;
     38  \endcode
    2439*/
    25 
    26 namespace SOPHYA {
    2740
    2841//! Default constructor - SpecialSquareMatrix of size 0, SetSize() should be called before the object is used
Note: See TracChangeset for help on using the changeset viewer.