Changeset 3612 in Sophya for trunk/SophyaLib/BaseTools/stsrand.cc


Ignore:
Timestamp:
Apr 30, 2009, 7:06:50 PM (16 years ago)
Author:
ansari
Message:

Suite modifs / adaptation avec l'introduction de la suite des classes RandomGeneratorInterface et Cie , Reza 30/04/2009

File:
1 edited

Legend:

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

    r3599 r3612  
    99
    1010/*!
    11    \class RandomGenerator
     11   \class STSRandGen
    1212   \ingroup BaseTools
    1313   \brief Random number generator
     
    1717   random number generator used.
    1818
    19    \sa SOPHYA::ObjFileIO<RandomGenerator>
     19   \sa SOPHYA::ObjFileIO<STSRandGen>
    2020
    2121   \sa frand01 drand01 frandpm1 drandpm1
     
    2929static ThSafeOp* ths_rand = NULL;
    3030
    31 RandomGenerator::RandomGenerator(size_t n, bool tsafe)
     31STSRandGen::STSRandGen(size_t n, bool tsafe)
    3232{
    3333  if (ths_rand == NULL)  ths_rand = new ThSafeOp;
     
    4444}
    4545
    46 RandomGenerator::RandomGenerator(RandomGenerator const & rg)
     46STSRandGen::STSRandGen(STSRandGen const & rg)
    4747{
    4848  if (ths_rand == NULL)  ths_rand = new ThSafeOp;
     
    5959
    6060
    61 RandomGenerator::~RandomGenerator(void)
     61STSRandGen::~STSRandGen(void)
    6262{
    6363  // rien a faire
    6464}
    6565
    66 void RandomGenerator::SetBuffSize(size_t n)
     66void STSRandGen::SetBuffSize(size_t n)
    6767// redimensionnement du buffer
    6868{
     
    7373}
    7474
    75 void RandomGenerator::AutoInit(int lp)
     75void STSRandGen::AutoInit(int lp)
    7676// Initialisation automatique (pseudo) aleatoire du generateur.
    7777// L'initialiseur est donne par un codage du nombre de millisecondes
     
    133133    }
    134134  }
    135   if(lp>0) cout<<"RandomGenerator::AutoInit: "<<seed_16v[0]<<" "<<seed_16v[1]<<" "<<seed_16v[2]<<endl;
     135  if(lp>0) cout<<"STSRandGen::AutoInit: "<<seed_16v[0]<<" "<<seed_16v[1]<<" "<<seed_16v[2]<<endl;
    136136
    137137  // Initialise drand48()
     
    139139}
    140140
    141 void RandomGenerator::Init(long seed_val, int lp)
    142 {
    143   if (ths_rand == NULL)  ths_rand = new ThSafeOp;
    144   if(lp) cout << "RandomGenerator::Init(long seed=" << seed_val << ")" << endl;
     141void STSRandGen::Init(long seed_val, int lp)
     142{
     143  if (ths_rand == NULL)  ths_rand = new ThSafeOp;
     144  if(lp) cout << "STSRandGen::Init(long seed=" << seed_val << ")" << endl;
    145145  ths_rand->lock();
    146146  srand48(seed_val);
     
    149149}
    150150
    151 void RandomGenerator::Init(unsigned short seed_16v[3], int lp)
    152 {
    153   if (ths_rand == NULL)  ths_rand = new ThSafeOp;
    154   if(lp) cout << "RandomGenerator::Init(u_short seed_16v[3]=" << seed_16v[0]
     151void STSRandGen::Init(unsigned short seed_16v[3], int lp)
     152{
     153  if (ths_rand == NULL)  ths_rand = new ThSafeOp;
     154  if(lp) cout << "STSRandGen::Init(u_short seed_16v[3]=" << seed_16v[0]
    155155              << "," << seed_16v[1] << "," << seed_16v[2] << ")" << endl;
    156156  ths_rand->lock();
     
    159159}
    160160
    161 void RandomGenerator::GetSeed(unsigned short seed_16v[3], int lp)
     161void STSRandGen::GetSeed(unsigned short seed_16v[3], int lp)
    162162{
    163163  if (ths_rand == NULL)  ths_rand = new ThSafeOp;
     
    165165  GetSeed_P(seed_16v);
    166166  ths_rand->unlock();
    167   if(lp) cout << "RandomGenerator::GetSeed(u_short seed_16v[3]=" << seed_16v[0]
     167  if(lp) cout << "STSRandGen::GetSeed(u_short seed_16v[3]=" << seed_16v[0]
    168168              << "," << seed_16v[1] << "," << seed_16v[2] << ")" << endl;
    169169  return;
    170170}
    171171
    172 void RandomGenerator::Init_P(unsigned short seed_16v[3])
     172void STSRandGen::Init_P(unsigned short seed_16v[3])
    173173{
    174174  seed48(seed_16v);
    175175}
    176176
    177 void RandomGenerator::GetSeed_P(unsigned short seed_16v[3])
     177void STSRandGen::GetSeed_P(unsigned short seed_16v[3])
    178178{
    179179  unsigned short seed[3] = {0,0,0};
     
    186186}
    187187
    188 r_8 RandomGenerator::Gaussian()
     188r_8 STSRandGen::Gaussian()
    189189{
    190190  r_8 A=Next();
     
    194194
    195195
    196 uint_8 RandomGenerator::Poisson(double mu,double mumax)
     196uint_8 STSRandGen::Poisson(double mu,double mumax)
    197197{
    198198  double pp,ppi,x;
     
    218218}
    219219
    220 void RandomGenerator::GenSeq(void)
     220void STSRandGen::GenSeq(void)
    221221{
    222222  ths_rand->lock();
     
    228228//----------------------------------------------------------
    229229// Classe pour la gestion de persistance
    230 // ObjFileIO<RandomGenerator>
     230// ObjFileIO<STSRandGen>
    231231//----------------------------------------------------------
    232232
    233233/* --Methode-- */
    234234DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    235 void        ObjFileIO<RandomGenerator>::WriteSelf(POutPersist& s) const
     235void        ObjFileIO<STSRandGen>::WriteSelf(POutPersist& s) const
    236236{
    237237  if (dobj == NULL)
    238     throw NullPtrError("ObjFileIO<RandomGenerator>::WriteSelf() dobj=NULL");
     238    throw NullPtrError("ObjFileIO<STSRandGen>::WriteSelf() dobj=NULL");
    239239  ths_rand->lock();  // thread-safety
    240240  uint_4 itab[6];
     
    259259/* --Methode-- */
    260260DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    261 void        ObjFileIO<RandomGenerator>::ReadSelf(PInPersist& s)
     261void        ObjFileIO<STSRandGen>::ReadSelf(PInPersist& s)
    262262{
    263263  uint_4 itab[6];
     
    268268  s.Get(ix);  // Taille du tableau intermediaire
    269269
    270   if (dobj == NULL) dobj = new RandomGenerator(sz, (sz>0)?true:false);
     270  if (dobj == NULL) dobj = new STSRandGen(sz, (sz>0)?true:false);
    271271  dobj->idx_ = ix;
    272272  if (sz > 0) {
     
    288288// ---------------------------------------------------------
    289289#ifdef __CXX_PRAGMA_TEMPLATES__
    290 #pragma define_template ObjFileIO<RandomGenerator>
     290#pragma define_template ObjFileIO<STSRandGen>
    291291#endif
    292292
    293293#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
    294 template class ObjFileIO<RandomGenerator>;
     294template class ObjFileIO<STSRandGen>;
    295295#endif
    296296// ---------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.