Index: trunk/SophyaLib/Samba/alm.cc
===================================================================
--- trunk/SophyaLib/Samba/alm.cc	(revision 3612)
+++ trunk/SophyaLib/Samba/alm.cc	(revision 3613)
@@ -20,7 +20,6 @@
 
   //alm.ReSize(nlmax);
-  this->ReSizeRow(nlmax+1);
-  RandomGenerator rg(1, false);
-  GenFromCl(clin, fwhm, rg);
+  this->ReSizeRow(nlmax+1); 
+  GenFromCl(clin, fwhm, *(RandomGeneratorInterface::GetGlobalRandGenP()) );
 }
 
@@ -29,5 +28,5 @@
 */
 template <class T>
-Alm<T>::Alm(const TVector<T>& clin, const r_8 fwhm, RandomGenerator & rg)
+Alm<T>::Alm(const TVector<T>& clin, const r_8 fwhm, RandomGeneratorInterface & rg)
 {
   int_4 nlmax= clin.NElts()-1;
@@ -41,5 +40,5 @@
 
 template <class T>
-void Alm<T>::GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGenerator & rg)
+void Alm<T>::GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGeneratorInterface & rg)
 {
   /*=======================================================================
Index: trunk/SophyaLib/Samba/alm.h
===================================================================
--- trunk/SophyaLib/Samba/alm.h	(revision 3612)
+++ trunk/SophyaLib/Samba/alm.h	(revision 3613)
@@ -6,5 +6,5 @@
 #define ALM_SEEN
 
-#include "stsrand.h"
+#include "randinterf.h"
 #include "nbmath.h"
 #include "triangmtx.h"
@@ -26,5 +26,5 @@
   Alm(const TVector<T> & clin, const r_8 fwhm) ;
 //! Constructor, generates alm from a cl vector, using the specified random generator object
-  Alm(const TVector<T> & clin, const r_8 fwhm, RandomGenerator & rg);
+  Alm(const TVector<T> & clin, const r_8 fwhm, RandomGeneratorInterface& rg);
 
 //! Resize with a new lmax 
@@ -41,5 +41,5 @@
 
 private:
-  void GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGenerator& rg);
+  void GenFromCl(const TVector<T> & clin, const r_8 fwhm, RandomGeneratorInterface& rg);
 };
 
Index: trunk/SophyaLib/Samba/sphericaltransformserver.cc
===================================================================
--- trunk/SophyaLib/Samba/sphericaltransformserver.cc	(revision 3612)
+++ trunk/SophyaLib/Samba/sphericaltransformserver.cc	(revision 3613)
@@ -6,5 +6,4 @@
 #include "sphericaltransformserver.h"
 #include "tvector.h"
-#include "stsrand.h"
 #include "nbmath.h"
 #include "timing.h"
@@ -156,5 +155,5 @@
 template<class T>
 SphericalTransformServer<T>::SphericalTransformServer()
-: rg_(1, false) 
+: rgp_(RandomGeneratorInterface::GetGlobalRandGenP()) 
 {
   fftIntfPtr_=new FFTPackServer(true); // preserveinput = true
@@ -164,6 +163,6 @@
 //!  Constructor with the specification of a RandomGenerator object to be used by GenerateFromCl 
 template<class T>
-SphericalTransformServer<T>::SphericalTransformServer(RandomGenerator const & rg)
-: rg_(rg) 
+SphericalTransformServer<T>::SphericalTransformServer(RandomGeneratorInterface& rg)
+: rgp_(&rg) 
 {
   fftIntfPtr_=new FFTPackServer(true); // preserveinput = true
@@ -1312,6 +1311,6 @@
   //  Alm<T> a2lme = almFromCl(Cle, fwhm);
   // Alm<T> a2lmb = almFromCl(Clb, fwhm);
-  Alm<T> a2lme(Cle, fwhm, rg_);
-  Alm<T> a2lmb(Clb, fwhm, rg_);
+  Alm<T> a2lme(Cle, fwhm, *rgp_);
+  Alm<T> a2lmb(Clb, fwhm, *rgp_);
 
   GenerateFromAlm(sphq,sphu,pixelSizeIndex,a2lme,a2lmb); 
@@ -1330,5 +1329,5 @@
 {
 
-  Alm<T> alm(Cl, fwhm, rg_);
+  Alm<T> alm(Cl, fwhm, *rgp_);
   GenerateFromAlm(sph,pixelSizeIndex, alm ); 
 }
Index: trunk/SophyaLib/Samba/sphericaltransformserver.h
===================================================================
--- trunk/SophyaLib/Samba/sphericaltransformserver.h	(revision 3612)
+++ trunk/SophyaLib/Samba/sphericaltransformserver.h	(revision 3613)
@@ -5,5 +5,5 @@
 #include "fftservintf.h"
 #include "fftpserver.h"
-#include "stsrand.h"
+#include "randinterf.h"
 #include "alm.h"
 #include "lambdaBuilder.h"
@@ -19,6 +19,6 @@
  public:
 
-  SphericalTransformServer();  
-  SphericalTransformServer(RandomGenerator const & rg);  
+  explicit SphericalTransformServer();  
+  explicit SphericalTransformServer(RandomGeneratorInterface& rg);  
   virtual ~SphericalTransformServer(); 
   void SetFFTServer(FFTServerInterface* srv=NULL);
@@ -107,5 +107,5 @@
 
  FFTServerInterface* fftIntfPtr_;
- mutable RandomGenerator rg_;
+ mutable RandomGeneratorInterface* rgp_;
 
 };
Index: trunk/SophyaLib/TArray/utilarr.cc
===================================================================
--- trunk/SophyaLib/TArray/utilarr.cc	(revision 3612)
+++ trunk/SophyaLib/TArray/utilarr.cc	(revision 3613)
@@ -5,5 +5,5 @@
 #include "machdefs.h"
 #include "utilarr.h"
-#include "stsrand.h"
+#include "randr48.h"
 
 // Classe utilitaires
@@ -20,39 +20,64 @@
 */
 
-//! Constructor
-/*!
-  \param typ : generator type
-  \param m : mean parameter of the generator (if needed)
-  \param s : sigma parameter of the generator (if needed)
+/*!
+  \brief constructor using a global default random generator ( RandomGeneratorInterface::GetGlobalRandGenP() )
+  \param typ : generated random numbers distribution type: C_RND_Flat,C_RND_Gaussian,C_RND_Poisson,C_RND_Exponential
+  \param mean : mean value of the distribution 
+  \param sigma : standard deviation of the distribution 
  */
-static RandomGenerator* uarg_ = NULL;
-RandomSequence::RandomSequence(int typ, double m, double s)
-{
-  typ_ = (typ == Flat) ? Flat : Gaussian;
-  mean_ = m;
-  sig_ = s;
-  if (uarg_ == NULL) uarg_ = new RandomGenerator(1024, true);
-}
+RandomSequence::RandomSequence(int typ, double mean, double sigma)
+{
+  typ_ = (typ == Flat) ? C_RND_Flat: C_RND_Gaussian ;
+  mean_ = mean;
+  sig_ = sigma;
+  rgp_ = RandomGeneratorInterface::GetGlobalRandGenP();
+}
+
+
+/*!
+  \brief constructor with the specification of a RandomGenerator object to be used.
+  \param rgen : RandomGeneratorInterface object that should stay valid as long as the RandomSequence object exist.
+  \param typ : generated random numbers distribution type: C_RND_Flat,C_RND_Gaussian,C_RND_Poisson,C_RND_Exponential
+  \param mean : mean value of the distribution 
+  \param sigma : standard deviation of the distribution 
+ */
+RandomSequence::RandomSequence(RandomGeneratorInterface& rgen, RNDTypes rtyp, double mean, double sigma)
+{
+  typ_ = rtyp;
+  mean_ = mean;
+  sig_ = sigma;
+  rgp_ = &rgen;
+}
+
 RandomSequence::~RandomSequence()
 {
 }
 
-//! Return random sequence values.
-/*!
-  \return If typ = Flat : return [-1,+1]*sig + mean
-  \return If typ = Gaussian : return gaussian distributed
-                          with \b mean mean and sigma \b sig
- */
-double RandomSequence::Rand()
-{
-  if (typ_ == Flat) 
-    return(uarg_->Flatpm1()*sig_ + mean_);
-  else return(uarg_->Gaussian(sig_, mean_));
-}
-
+double RandomSequence::Next() const 
+{
+  switch (typ_) {
+    case C_RND_Flat :
+      return rgp_->Flatpm1()*sig_ + mean_;
+      break; 
+    case C_RND_Gaussian :
+      return rgp_->Gaussian(sig_, mean_);
+      break; 
+    case C_RND_Poisson :
+      return rgp_->Poisson(mean_);
+      break; 
+    case C_RND_Exponential :
+      return rgp_->Exponential();
+      break; 
+    default :
+      return rgp_->Flat01();
+      break; 
+
+  }
+}
+
+//!  \brief Return the next random number 
 MuTyV & RandomSequence::Value(sa_size_t k) const 
 {
-  if (typ_ == Flat) retv_ = uarg_->Flatpm1()*sig_ + mean_;
-  else retv_ = uarg_->Gaussian(sig_, mean_);
+  retv_ = Next();
   return retv_;
 }
Index: trunk/SophyaLib/TArray/utilarr.h
===================================================================
--- trunk/SophyaLib/TArray/utilarr.h	(revision 3612)
+++ trunk/SophyaLib/TArray/utilarr.h	(revision 3613)
@@ -8,4 +8,5 @@
 #include "machdefs.h"
 #include "mutyv.h"
+#include "randinterf.h"
 
 #include <stdlib.h>
@@ -56,12 +57,14 @@
 
   explicit RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.);
+  explicit RandomSequence(RandomGeneratorInterface& rgen, RNDTypes rtyp=C_RND_Gaussian, double mean=0., double sigma=1.);
   virtual  ~RandomSequence();
   virtual MuTyV & Value(sa_size_t k) const ;
-  double   Rand();
+  double   Next() const ;
 
 protected:
-  int typ_;            //!< random generation type
+  RNDTypes typ_;            //!< random generation type
   double mean_, sig_;  //!< generation parameters mean and sigma (if needed)
   mutable MuTyV retv_;
+  mutable RandomGeneratorInterface* rgp_;
 };
 
