Index: trunk/SophyaLib/BaseTools/Makefile
===================================================================
--- trunk/SophyaLib/BaseTools/Makefile	(revision 4018)
+++ trunk/SophyaLib/BaseTools/Makefile	(revision 4019)
@@ -4,59 +4,58 @@
  
 clean:
-	 rm -f $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)gnumd5.o
+	 rm -f $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randtmt64.o $(SOPHYAOBJP)randtmt32.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)tinymt32.o $(SOPHYAOBJP)tinymt64.o
 	rm -f $(SOPHYALIBP)libBaseTools.a
  
-$(SOPHYALIBP)libBaseTools.a : $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o
+$(SOPHYALIBP)libBaseTools.a : $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randtmt64.o $(SOPHYAOBJP)randtmt32.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)tinymt32.o $(SOPHYAOBJP)tinymt64.o
 	$(AR) $(ARFLAGS) $@ $? 
 	touch $(SOPHYAINCP)/SophyaConfInfo/libsophya.objlist
  
 $(SOPHYAOBJP)datatype.o: datatype.cc datatype.h \
-  $(SOPHYAINCP)machdefs.h
+ $(SOPHYAINCP)machdefs.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  datatype.cc
  
-$(SOPHYAOBJP)dvlist.o: dvlist.cc \
-  $(SOPHYAINCP)machdefs.h \
-  dvlist.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h mutyv.h timestamp.h \
-  $(SOPHYAINCP)strutil.h
+$(SOPHYAOBJP)dvlist.o: dvlist.cc $(SOPHYAINCP)machdefs.h \
+ dvlist.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
+ ppfbinstream.h rawstream.h ppfnametag.h mutyv.h timestamp.h \
+ $(SOPHYAINCP)strutil.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  dvlist.cc
  
 $(SOPHYAOBJP)fiondblock.o: fiondblock.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h datatype.h fiondblock.h ppersist.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h ndatablock.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h datatype.h \
+ fiondblock.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h ppfnametag.h \
+ ndatablock.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  fiondblock.cc
  
 $(SOPHYAOBJP)mutyv.o: mutyv.cc sopnamsp.h mutyv.h \
-  $(SOPHYAINCP)machdefs.h \
-  timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h
+ $(SOPHYAINCP)machdefs.h timestamp.h objfio.h \
+ anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+ rawstream.h ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  mutyv.cc
  
 $(SOPHYAOBJP)ndatablock.o: ndatablock.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h ndatablock.h anydataobj.h thsafeop.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h \
+ ndatablock.h anydataobj.h thsafeop.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ndatablock.cc
  
 $(SOPHYAOBJP)pexceptions.o: pexceptions.cc sopnamsp.h pexceptions.h \
-  $(SOPHYAINCP)machdefs.h
+ $(SOPHYAINCP)machdefs.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pexceptions.cc
  
 $(SOPHYAOBJP)ppersist.o: ppersist.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h \
-  ppfnametag.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h ppersist.h \
+ gnumd5.h ppfbinstream.h rawstream.h ppfnametag.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppersist.cc
  
 $(SOPHYAOBJP)ppfbinstream.o: ppfbinstream.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  ppfbinstream.h rawstream.h pexceptions.h
+ $(SOPHYAINCP)machdefs.h ppfbinstream.h \
+ rawstream.h pexceptions.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppfbinstream.cc
  
 $(SOPHYAOBJP)ppftpointerio.o: ppftpointerio.cc \
-  $(SOPHYAINCP)machdefs.h \
-  ppftpointerio.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h
+ $(SOPHYAINCP)machdefs.h ppftpointerio.h \
+ ppersist.h pexceptions.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppftpointerio.cc
+ 
  
 $(SOPHYAOBJP)randfmt.o: randfmt.cc randfmt.h \
@@ -66,40 +65,48 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randfmt.cc
  
+$(SOPHYAOBJP)randtmt32.o: randtmt32.cc randtmt32.h \
+  $(SOPHYAINCP)machdefs.h \
+  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+  rawstream.h ppfnametag.h randinterf.h tinymt32.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randtmt32.cc
+ 
+$(SOPHYAOBJP)randtmt64.o: randtmt64.cc randtmt64.h \
+  $(SOPHYAINCP)machdefs.h \
+  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+  rawstream.h ppfnametag.h randinterf.h tinymt64.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randtmt64.cc
+ 
 $(SOPHYAOBJP)randinterf.o: randinterf.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h randinterf.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h \
+ randinterf.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randinterf.cc
  
-$(SOPHYAOBJP)randr48.o: randr48.cc \
-  $(SOPHYAINCP)machdefs.h \
-  thsafeop.h pexceptions.h fiondblock.h ppersist.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h ndatablock.h anydataobj.h \
-  randr48.h objfio.h randinterf.h
+$(SOPHYAOBJP)randr48.o: randr48.cc $(SOPHYAINCP)machdefs.h \
+ thsafeop.h pexceptions.h fiondblock.h ppersist.h gnumd5.h ppfbinstream.h \
+ rawstream.h ppfnametag.h ndatablock.h anydataobj.h randr48.h objfio.h \
+ randinterf.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randr48.cc
  
 $(SOPHYAOBJP)rawstream.o: rawstream.cc sopnamsp.h rawstream.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  rawstream.cc
  
 $(SOPHYAOBJP)sophyainit.o: sophyainit.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  sophyainit.h pexceptions.h ppersist.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h fiondblock.h ndatablock.h anydataobj.h \
-  dvlist.h objfio.h mutyv.h timestamp.h randr48.h randinterf.h randfmt.h \
-  fiosegdb.h segdatablock.h thsafeop.h ppftpointerio.h ppfwrapstlv.h \
-  sversion.h
+ $(SOPHYAINCP)machdefs.h sophyainit.h \
+ pexceptions.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h fiondblock.h ndatablock.h anydataobj.h dvlist.h objfio.h \
+ mutyv.h timestamp.h randr48.h randinterf.h randfmt.h randtmt32.h randtmt64.h fiosegdb.h \
+ segdatablock.h thsafeop.h ppftpointerio.h ppfwrapstlv.h sversion.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sophyainit.cc
  
 $(SOPHYAOBJP)stsrand.o: stsrand.cc stsrand.h \
-  $(SOPHYAINCP)machdefs.h \
-  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h ndatablock.h thsafeop.h fiondblock.h
+ $(SOPHYAINCP)machdefs.h objfio.h anydataobj.h \
+ ppersist.h pexceptions.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h ndatablock.h thsafeop.h fiondblock.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  stsrand.cc
  
-$(SOPHYAOBJP)timestamp.o: timestamp.cc \
-  $(SOPHYAINCP)machdefs.h \
-  timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h
+$(SOPHYAOBJP)timestamp.o: timestamp.cc $(SOPHYAINCP)machdefs.h \
+ timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
+ ppfbinstream.h rawstream.h ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  timestamp.cc
  
@@ -107,7 +114,12 @@
 	$(CCOMPILE) -o $@  dSFMT.c
  
-$(SOPHYAOBJP)gnumd5.o: gnumd5.c \
-  $(SOPHYAINCP)machdefs.h \
-  bithelp.h gnumd5.h
+$(SOPHYAOBJP)gnumd5.o: gnumd5.c $(SOPHYAINCP)machdefs.h \
+ bithelp.h gnumd5.h
 	$(CCOMPILE) -o $@  gnumd5.c
  
+$(SOPHYAOBJP)tinymt32.o: tinymt32.c tinymt32.h
+	$(CCOMPILE) -o $@  tinymt32.c
+ 
+$(SOPHYAOBJP)tinymt64.o: tinymt64.c tinymt64.h
+	$(CCOMPILE) -o $@  tinymt64.c
+ 
Index: trunk/SophyaLib/BaseTools/objlist.list
===================================================================
--- trunk/SophyaLib/BaseTools/objlist.list	(revision 4018)
+++ trunk/SophyaLib/BaseTools/objlist.list	(revision 4019)
@@ -11,4 +11,6 @@
 ppftpointerio.o
 randfmt.o
+randtmt32.o
+randtmt64.o
 randinterf.o
 randr48.o
@@ -17,2 +19,4 @@
 stsrand.o
 timestamp.o
+tinymt32.o
+tinymt64.o
Index: trunk/SophyaLib/BaseTools/randinterf.cc
===================================================================
--- trunk/SophyaLib/BaseTools/randinterf.cc	(revision 4018)
+++ trunk/SophyaLib/BaseTools/randinterf.cc	(revision 4019)
@@ -88,6 +88,6 @@
 /////////////////////////////////////////////////////////////////////////
 void RandomGeneratorInterface::GenerateSeedVector(int nseed,vector<uint_2>& seed,int lp)
-// renvoie un vecteur de nseed+2 entiers 32 bits
-// [0 - 2] = codage sur 48 bits du nombre (melange) de microsec depuis l'origine
+// renvoie un vecteur de 3+nseed entiers 16 bits
+// [0 - 2] = codage sur 3*16 = 48 bits du nombre (melange) de microsec depuis l'origine
 // [3 -> 3+ngene-1] = entiers aleatoires (poor man generator)
 //
@@ -112,5 +112,5 @@
   // Calcul du temps ecoule depuis l'origine en microsecondes
   uint_8 tmicro70 = (uint_8)now.tv_sec*(uint_8)1000000 + (uint_8)now.tv_usec;
-  if(lp>1) cout<<"."<<now.tv_sec<<" sec + "<<now.tv_usec<<" musec = "<<tmicro70<<" musec"<<endl;
+  if(lp>1) cout<<".since orig: "<<now.tv_sec<<" sec + "<<now.tv_usec<<" musec = "<<tmicro70<<" musec"<<endl;
   // Remplissage du tableau de 48 bits
   uint_2 b[48]; uint_8 tdum = tmicro70;
@@ -125,5 +125,5 @@
   for(int ip=0;ip<16;ip++) {
     if(ip%3==1) swap(b[ip],b[32+ip]);
-    else if(ip%3==2) swap(b[ip],b[16-ip]);
+    else if(ip%3==2) swap(b[ip],b[16+ip]);
   }
   if(lp>2) {
@@ -139,5 +139,7 @@
     for(int ip=0;ip<16;ip++) {seed[i] += w*b[i*16+ip]; w *= 2;}
   }
-  if(lp>0) cout<<"seed(time): "<<seed[0]<<" "<<seed[1]<<" "<<seed[2]<<endl;
+  if(lp>0) cout<<"seed_time[0-2]: "<<seed[0]<<" "<<seed[1]<<" "<<seed[2]<<endl;
+  // On recree tmicro70 avec les bits melanges
+  tmicro70 = uint_8(seed[0]) | (uint_8(seed[1])<<16) | (uint_8(seed[2])<<32);
 
   // ---
@@ -160,5 +162,5 @@
   // the requirements. The constants below are arbitrary otherwise
   uint_4 seed0 = uint_4(tmicro70&0xFFFFFFFFULL);
-  if(lp>2) cout<<"seed0(time): "<<seed0<<endl;
+  if(lp>2) cout<<"seed0_time_init_t88: "<<seed0<<endl;
   uint_4 state_s1, state_s2, state_s3;
   state_s1 = 1243598713U ^ seed0; if (state_s1 <  2) state_s1 = 1243598713U;
@@ -177,5 +179,5 @@
     uint_2 s = uint_2( (s1^s2^s3)&0xFFFFU );
     seed.push_back(s);
-    if(lp>0) cout<<"seed(t88): "<<seed[3+nfill]<<endl;
+    if(lp>0) cout<<"seed_t88["<<nfill+3<<"]: "<<seed[3+nfill]<<endl;
     nfill++;
   }
@@ -356,11 +358,11 @@
 r_8 RandomGeneratorInterface::GaussianPolarBoxMuller()
 {
-double x1,x2,w;
-do {
+ double x1,x2,w;
+ do {
    x1 = 2.0 * Next() - 1.0;
    x2 = 2.0 * Next() - 1.0;
    w = x1 * x1 + x2 * x2;
-   } while ( w >= 1.0 || w==0. );
-return x1 * sqrt(-2.0*log(w)/w);
+ } while ( w >= 1.0 || w==0. );
+ return x1 * sqrt(-2.0*log(w)/w);
 }
 
@@ -368,19 +370,19 @@
 r_8 RandomGeneratorInterface::GaussianRatioUnif()
 {
-double u,v,x;
-while(true) {
-  do {u = Next();} while ( u == 0. );
-  v = (2.0*Next()-1.0)*s2se_RatioUnif;
-  x = v/u;
-  if(x*x <= 5.0-4.0*ep1q_RatioUnif*u) break;
-  if(x*x<4.0*epm135_RatioUnif/u+1.4)
-    if(v*v<-4.0*u*u*log(u)) break;
-}
-return x;
+ double u,v,x;
+ while(true) {
+   do {u = Next();} while ( u == 0. );
+   v = (2.0*Next()-1.0)*s2se_RatioUnif;
+   x = v/u;
+   if(x*x <= 5.0-4.0*ep1q_RatioUnif*u) break;
+   if(x*x<4.0*epm135_RatioUnif/u+1.4)
+     if(v*v<-4.0*u*u*log(u)) break;
+ }
+ return x;
 }
 
 r_8 RandomGeneratorInterface::GaussianLevaRatioUnif()
 {
-double u,v,x,y,q;
+ double u,v,x,y,q;
  do {
    u = 1.-Next();  // in ]0,1]
@@ -525,38 +527,23 @@
    * This implementation does one-sided upper-tailed deviates.
    */
-
-  if (s < slim)
-    {
-      /* For small s, use a direct rejection method. The limit s < 1
-         can be adjusted to optimise the overall efficiency */
-      double x;
-      do
-        {
-          x = Gaussian();
-        }
-      while (x < s);
-      return x;
-    }
-  else
-    {
-      /* Use the "supertail" deviates from the last two steps
-       * of Marsaglia's rectangle-wedge-tail method, as described
-       * in Knuth, v2, 3rd ed, pp 123-128.  (See also exercise 11, p139,
-       * and the solution, p586.)
-       */
-      double u, v, x;
-      do
-        {
-          u = Next();
-          do
-            {
-              v = Next();
-            }
-          while (v == 0.0);
-          x = sqrt (s * s - 2 * log (v));
-        }
-      while (x * u > s);
-      return x;
-    }
+  if(s < slim) {
+    /* For small s, use a direct rejection method. The limit s < 1
+       can be adjusted to optimise the overall efficiency */
+    double x;
+    do {x = Gaussian();} while (x < s);
+    return x;
+  } else {
+    /* Use the "supertail" deviates from the last two steps
+     * of Marsaglia's rectangle-wedge-tail method, as described
+     * in Knuth, v2, 3rd ed, pp 123-128.  (See also exercise 11, p139,
+     * and the solution, p586.)
+     */
+    double u, v, x;
+    do {u = Next();
+      do {v = Next();} while (v == 0.0);
+      x = sqrt (s * s - 2 * log (v));
+    } while (x * u > s);
+    return x;
+  }
 }
 
Index: trunk/SophyaLib/BaseTools/randtmt32.cc
===================================================================
--- trunk/SophyaLib/BaseTools/randtmt32.cc	(revision 4019)
+++ trunk/SophyaLib/BaseTools/randtmt32.cc	(revision 4019)
@@ -0,0 +1,116 @@
+#include <math.h> 
+#include <stdlib.h>
+
+#include "randtmt32.h"
+
+#ifndef UINT32_C
+#  define UINT32_C(v) (v ## UL) 
+#endif
+#include "tinymt32.h"
+
+namespace SOPHYA {
+
+//----------------------------------------------------------------
+// Implementation d'un generateur aleatoire utilisant le code 
+// Tiny Mersenne Twister (TinyMT).
+// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+
+
+TinyMT32RandGen::TinyMT32RandGen(uint_4 seed)
+{
+  // On est oblige de faire new car la structure tinymt32_t pas defini ds randtmt32.h 
+  tinymt32_ptr_ = new tinymt32_t;
+  tinymt32_init(tinymt32_ptr_,seed);
+}
+
+TinyMT32RandGen::~TinyMT32RandGen()
+{
+// Ne pas oublier de faire le delete 
+  delete tinymt32_ptr_;
+}
+
+void TinyMT32RandGen::ShowRandom()
+{
+  cout<<"RandomGenerator is TinyMT32RandGen"<<endl;
+}
+
+void TinyMT32RandGen::SetSeed(uint_4 seed)
+{
+  tinymt32_init(tinymt32_ptr_,seed);
+}
+
+void TinyMT32RandGen::SetSeed(vector<uint_4> seed)
+{
+  if(seed.size()<=0) return;
+  int key_length = (int)seed.size();
+  uint_4* init_key = new uint_4[key_length];
+  for(int i=0;i<key_length;i++) init_key[i] = seed[i];
+
+  tinymt32_init_by_array(tinymt32_ptr_,init_key,key_length);
+
+  delete [] init_key;
+}
+
+r_8 TinyMT32RandGen::Next()
+{
+  return (r_8)tinymt32_generate_float(tinymt32_ptr_);
+}
+
+void TinyMT32RandGen::AutoInit(int lp)
+// init automatique avec 2 mots de 32 bits
+{
+  vector<uint_2> seed;
+  GenerateSeedVector(1,seed,lp);
+  vector<uint_4> s;
+  uint_4 s4;
+  s4 = uint_4(seed[0]) | (uint_4(seed[1])<<16);
+  s.push_back(s4);
+  s4 = uint_4(seed[2]) | (uint_4(seed[3])<<16);
+  s.push_back(s4);
+  SetSeed(s);
+}
+
+//----------------------------------------------------------
+// Classe pour la gestion de persistance
+// ObjFileIO<TinyMT32RandGen>
+//----------------------------------------------------------
+
+/* --Methode-- */
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<TinyMT32RandGen>::WriteSelf(POutPersist& s) const
+{
+  if (dobj == NULL)
+    throw NullPtrError("ObjFileIO<TinyMT32RandGen>::WriteSelf() dobj=NULL");
+  for(int i=0;i<4;i++)s.Put((uint_4)dobj->tinymt32_ptr_->status[i]);
+  s.Put((uint_4)dobj->tinymt32_ptr_->mat1);
+  s.Put((uint_4)dobj->tinymt32_ptr_->mat2);
+  s.Put((uint_4)dobj->tinymt32_ptr_->tmat);
+  return;
+}
+
+/* --Methode-- */
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<TinyMT32RandGen>::ReadSelf(PInPersist& s)
+{
+  if(dobj == NULL) dobj = new TinyMT32RandGen();
+  uint_4 v;
+  for(int i=0;i<4;i++) {
+    s.Get(v);
+    dobj->tinymt32_ptr_->status[i] = v;
+  }
+  s.Get(v); dobj->tinymt32_ptr_->mat1 = v;
+  s.Get(v); dobj->tinymt32_ptr_->mat2 = v;
+  s.Get(v); dobj->tinymt32_ptr_->tmat = v;
+  return;
+}
+
+// ---------------------------------------------------------
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template ObjFileIO<TinyMT32RandGen>
+#endif
+
+#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
+template class ObjFileIO<TinyMT32RandGen>;
+#endif
+
+}  /* namespace SOPHYA */
Index: trunk/SophyaLib/BaseTools/randtmt32.h
===================================================================
--- trunk/SophyaLib/BaseTools/randtmt32.h	(revision 4019)
+++ trunk/SophyaLib/BaseTools/randtmt32.h	(revision 4019)
@@ -0,0 +1,56 @@
+#ifndef RANDTMT32_H_SEEN
+#define RANDTMT32_H_SEEN
+
+// Classes TinyMT32RandGen
+// Generateur aleatoire utilisant le code TinyMT 32 bits 
+//
+// R. Ansari          (C) UPS+LAL IN2P3/CNRS  2009
+// C. Magneville      (C) DAPNIA/SPP  CEA     2009
+
+
+#include "machdefs.h"
+#include "objfio.h"
+
+#include "randinterf.h"
+
+#include <vector>
+
+//--- Declaration de la struct definie ds tinymt32.h - inclus uniquement dans le .cc  
+struct TINYMT32_T ;
+typedef struct TINYMT32_T tinymt32_t;
+//------------------- 
+
+namespace SOPHYA {
+
+//! Pseudorandom number generator class using dSFMT code 
+class TinyMT32RandGen : public RandomGeneratorInterface {
+
+ public:
+  TinyMT32RandGen(uint_4 seed=12345);
+  virtual ~TinyMT32RandGen();
+
+  virtual void SetSeed(uint_4 seed);
+  virtual void SetSeed(vector<uint_4> seed);
+  virtual void AutoInit(int lp=0);
+  virtual void ShowRandom();
+
+  friend class ObjFileIO<TinyMT32RandGen> ;
+
+ protected:
+  virtual r_8 Next();
+  tinymt32_t* tinymt32_ptr_;   // Pointeur car tinymt32_t pas encore defini
+
+};
+
+// Classe pour la gestion de persistance PPF :  ObjFileIO<TinyMT32RandGen>
+
+/*! Writes the random generator object state in the POutPersist stream \b os */
+inline POutPersist& operator << (POutPersist& os, TinyMT32RandGen & obj)
+{ ObjFileIO<TinyMT32RandGen> fio(&obj);  fio.Write(os);  return(os); }
+/*! Reads the random generator object state from the PInPersist stream \b is */
+inline PInPersist& operator >> (PInPersist& is, TinyMT32RandGen & obj)
+{ ObjFileIO<TinyMT32RandGen> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
+
+} /* namespace SOPHYA */
+
+#endif 
Index: trunk/SophyaLib/BaseTools/randtmt64.cc
===================================================================
--- trunk/SophyaLib/BaseTools/randtmt64.cc	(revision 4019)
+++ trunk/SophyaLib/BaseTools/randtmt64.cc	(revision 4019)
@@ -0,0 +1,116 @@
+#include <math.h> 
+#include <stdlib.h>
+
+#include "randtmt64.h"
+
+#ifndef UINT64_C
+#  define UINT64_C(v) (v ## ULL) 
+#endif
+#include "tinymt64.h"
+
+namespace SOPHYA {
+
+//----------------------------------------------------------------
+// Implementation d'un generateur aleatoire utilisant le code 
+// Tiny Mersenne Twister (TinyMT).
+// http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+
+
+TinyMT64RandGen::TinyMT64RandGen(uint_8 seed)
+{
+  // On est oblige de faire new car la structure tinymt64_t pas defini ds randtmt64.h 
+  tinymt64_ptr_ = new tinymt64_t;
+  tinymt64_init(tinymt64_ptr_,seed);
+}
+
+TinyMT64RandGen::~TinyMT64RandGen()
+{
+// Ne pas oublier de faire le delete 
+  delete tinymt64_ptr_;
+}
+
+void TinyMT64RandGen::ShowRandom()
+{
+  cout<<"RandomGenerator is TinyMT64RandGen"<<endl;
+}
+
+void TinyMT64RandGen::SetSeed(uint_8 seed)
+{
+  tinymt64_init(tinymt64_ptr_,seed);
+}
+
+void TinyMT64RandGen::SetSeed(vector<uint_8> seed)
+{
+  if(seed.size()<=0) return;
+  int key_length = (int)seed.size();
+  uint_8* init_key = new uint_8[key_length];
+  for(int i=0;i<key_length;i++) init_key[i] = seed[i];
+
+  tinymt64_init_by_array(tinymt64_ptr_,init_key,key_length);
+
+  delete [] init_key;
+}
+
+r_8 TinyMT64RandGen::Next()
+{
+  return tinymt64_generate_double(tinymt64_ptr_);
+}
+
+void TinyMT64RandGen::AutoInit(int lp)
+// init automatique avec 2 mots de 64 bits
+{
+  vector<uint_2> seed;
+  GenerateSeedVector(5,seed,lp);
+  vector<uint_8> s;
+  uint_8 s8;
+  s8 = uint_8(seed[0]) | (uint_8(seed[1])<<16) | (uint_8(seed[2])<<32) | (uint_8(seed[3])<<48);
+  s.push_back(s8);
+  s8 = uint_8(seed[4]) | (uint_8(seed[5])<<16) | (uint_8(seed[6])<<32) | (uint_8(seed[7])<<48);
+  s.push_back(s8);
+  SetSeed(s);
+}
+
+//----------------------------------------------------------
+// Classe pour la gestion de persistance
+// ObjFileIO<TinyMT64RandGen>
+//----------------------------------------------------------
+
+/* --Methode-- */
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<TinyMT64RandGen>::WriteSelf(POutPersist& s) const
+{
+  if (dobj == NULL)
+    throw NullPtrError("ObjFileIO<TinyMT64RandGen>::WriteSelf() dobj=NULL");
+  for(int i=0;i<2;i++)s.Put((uint_8)dobj->tinymt64_ptr_->status[i]);
+  s.Put((uint_4)dobj->tinymt64_ptr_->mat1);
+  s.Put((uint_4)dobj->tinymt64_ptr_->mat2);
+  s.Put((uint_8)dobj->tinymt64_ptr_->tmat);
+  return;
+}
+
+/* --Methode-- */
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<TinyMT64RandGen>::ReadSelf(PInPersist& s)
+{
+  if(dobj == NULL) dobj = new TinyMT64RandGen();
+  uint_4 v4; uint_8 v8;
+  for(int i=0;i<2;i++) {
+    s.Get(v8);
+    dobj->tinymt64_ptr_->status[i] = v8;
+  }
+  s.Get(v4); dobj->tinymt64_ptr_->mat1 = v4;
+  s.Get(v4); dobj->tinymt64_ptr_->mat2 = v4;
+  s.Get(v8); dobj->tinymt64_ptr_->tmat = v8;
+  return;
+}
+
+// ---------------------------------------------------------
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template ObjFileIO<TinyMT64RandGen>
+#endif
+
+#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
+template class ObjFileIO<TinyMT64RandGen>;
+#endif
+
+}  /* namespace SOPHYA */
Index: trunk/SophyaLib/BaseTools/randtmt64.h
===================================================================
--- trunk/SophyaLib/BaseTools/randtmt64.h	(revision 4019)
+++ trunk/SophyaLib/BaseTools/randtmt64.h	(revision 4019)
@@ -0,0 +1,56 @@
+#ifndef RANDTMT64_H_SEEN
+#define RANDTMT64_H_SEEN
+
+// Classes TinyMT64RandGen
+// Generateur aleatoire utilisant le code TinyMT 64 bits 
+//
+// R. Ansari          (C) UPS+LAL IN2P3/CNRS  2009
+// C. Magneville      (C) DAPNIA/SPP  CEA     2009
+
+
+#include "machdefs.h"
+#include "objfio.h"
+
+#include "randinterf.h"
+
+#include <vector>
+
+//--- Declaration de la struct definie ds tinymt64.h - inclus uniquement dans le .cc  
+struct TINYMT64_T ;
+typedef struct TINYMT64_T tinymt64_t;
+//------------------- 
+
+namespace SOPHYA {
+
+//! Pseudorandom number generator class using dSFMT code 
+class TinyMT64RandGen : public RandomGeneratorInterface {
+
+ public:
+  TinyMT64RandGen(uint_8 seed=12345);
+  virtual ~TinyMT64RandGen();
+
+  virtual void SetSeed(uint_8 seed);
+  virtual void SetSeed(vector<uint_8> seed);
+  virtual void AutoInit(int lp=0);
+  virtual void ShowRandom();
+
+  friend class ObjFileIO<TinyMT64RandGen> ;
+
+ protected:
+  virtual r_8 Next();
+  tinymt64_t* tinymt64_ptr_;   // Pointeur car tinymt64_t pas encore defini
+
+};
+
+// Classe pour la gestion de persistance PPF :  ObjFileIO<TinyMT64RandGen>
+
+/*! Writes the random generator object state in the POutPersist stream \b os */
+inline POutPersist& operator << (POutPersist& os, TinyMT64RandGen & obj)
+{ ObjFileIO<TinyMT64RandGen> fio(&obj);  fio.Write(os);  return(os); }
+/*! Reads the random generator object state from the PInPersist stream \b is */
+inline PInPersist& operator >> (PInPersist& is, TinyMT64RandGen & obj)
+{ ObjFileIO<TinyMT64RandGen> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
+
+} /* namespace SOPHYA */
+
+#endif 
Index: trunk/SophyaLib/BaseTools/smakefile
===================================================================
--- trunk/SophyaLib/BaseTools/smakefile	(revision 4018)
+++ trunk/SophyaLib/BaseTools/smakefile	(revision 4019)
@@ -4,59 +4,58 @@
  
 clean:
-	 rm -f $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)gnumd5.o
+	 rm -f $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randtmt64.o $(SOPHYAOBJP)randtmt32.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)tinymt32.o $(SOPHYAOBJP)tinymt64.o
 	rm -f $(SOPHYALIBP)libBaseTools.a
  
-$(SOPHYALIBP)libBaseTools.a : $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o
+$(SOPHYALIBP)libBaseTools.a : $(SOPHYAOBJP)datatype.o $(SOPHYAOBJP)dSFMT.o $(SOPHYAOBJP)dvlist.o $(SOPHYAOBJP)fiondblock.o $(SOPHYAOBJP)gnumd5.o $(SOPHYAOBJP)mutyv.o $(SOPHYAOBJP)ndatablock.o $(SOPHYAOBJP)pexceptions.o $(SOPHYAOBJP)ppersist.o $(SOPHYAOBJP)ppfbinstream.o $(SOPHYAOBJP)ppftpointerio.o $(SOPHYAOBJP)randtmt64.o $(SOPHYAOBJP)randtmt32.o $(SOPHYAOBJP)randfmt.o $(SOPHYAOBJP)randinterf.o $(SOPHYAOBJP)randr48.o $(SOPHYAOBJP)rawstream.o $(SOPHYAOBJP)sophyainit.o $(SOPHYAOBJP)stsrand.o $(SOPHYAOBJP)timestamp.o $(SOPHYAOBJP)tinymt32.o $(SOPHYAOBJP)tinymt64.o
 	$(AR) $(ARFLAGS) $@ $? 
 	touch $(SOPHYAINCP)/SophyaConfInfo/libsophya.objlist
  
 $(SOPHYAOBJP)datatype.o: datatype.cc datatype.h \
-  $(SOPHYAINCP)machdefs.h
+ $(SOPHYAINCP)machdefs.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  datatype.cc
  
-$(SOPHYAOBJP)dvlist.o: dvlist.cc \
-  $(SOPHYAINCP)machdefs.h \
-  dvlist.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h mutyv.h timestamp.h \
-  $(SOPHYAINCP)strutil.h
+$(SOPHYAOBJP)dvlist.o: dvlist.cc $(SOPHYAINCP)machdefs.h \
+ dvlist.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
+ ppfbinstream.h rawstream.h ppfnametag.h mutyv.h timestamp.h \
+ $(SOPHYAINCP)strutil.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  dvlist.cc
  
 $(SOPHYAOBJP)fiondblock.o: fiondblock.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h datatype.h fiondblock.h ppersist.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h ndatablock.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h datatype.h \
+ fiondblock.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h ppfnametag.h \
+ ndatablock.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  fiondblock.cc
  
 $(SOPHYAOBJP)mutyv.o: mutyv.cc sopnamsp.h mutyv.h \
-  $(SOPHYAINCP)machdefs.h \
-  timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h
+ $(SOPHYAINCP)machdefs.h timestamp.h objfio.h \
+ anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+ rawstream.h ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  mutyv.cc
  
 $(SOPHYAOBJP)ndatablock.o: ndatablock.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h ndatablock.h anydataobj.h thsafeop.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h \
+ ndatablock.h anydataobj.h thsafeop.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ndatablock.cc
  
 $(SOPHYAOBJP)pexceptions.o: pexceptions.cc sopnamsp.h pexceptions.h \
-  $(SOPHYAINCP)machdefs.h
+ $(SOPHYAINCP)machdefs.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pexceptions.cc
  
 $(SOPHYAOBJP)ppersist.o: ppersist.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h \
-  ppfnametag.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h ppersist.h \
+ gnumd5.h ppfbinstream.h rawstream.h ppfnametag.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppersist.cc
  
 $(SOPHYAOBJP)ppfbinstream.o: ppfbinstream.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  ppfbinstream.h rawstream.h pexceptions.h
+ $(SOPHYAINCP)machdefs.h ppfbinstream.h \
+ rawstream.h pexceptions.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppfbinstream.cc
  
 $(SOPHYAOBJP)ppftpointerio.o: ppftpointerio.cc \
-  $(SOPHYAINCP)machdefs.h \
-  ppftpointerio.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h
+ $(SOPHYAINCP)machdefs.h ppftpointerio.h \
+ ppersist.h pexceptions.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ppftpointerio.cc
+ 
  
 $(SOPHYAOBJP)randfmt.o: randfmt.cc randfmt.h \
@@ -66,40 +65,48 @@
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randfmt.cc
  
+$(SOPHYAOBJP)randtmt32.o: randtmt32.cc randtmt32.h \
+  $(SOPHYAINCP)machdefs.h \
+  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+  rawstream.h ppfnametag.h randinterf.h tinymt32.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randtmt32.cc
+ 
+$(SOPHYAOBJP)randtmt64.o: randtmt64.cc randtmt64.h \
+  $(SOPHYAINCP)machdefs.h \
+  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
+  rawstream.h ppfnametag.h randinterf.h tinymt64.h
+	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randtmt64.cc
+ 
 $(SOPHYAOBJP)randinterf.o: randinterf.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h randinterf.h anydataobj.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h \
+ randinterf.h anydataobj.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randinterf.cc
  
-$(SOPHYAOBJP)randr48.o: randr48.cc \
-  $(SOPHYAINCP)machdefs.h \
-  thsafeop.h pexceptions.h fiondblock.h ppersist.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h ndatablock.h anydataobj.h \
-  randr48.h objfio.h randinterf.h
+$(SOPHYAOBJP)randr48.o: randr48.cc $(SOPHYAINCP)machdefs.h \
+ thsafeop.h pexceptions.h fiondblock.h ppersist.h gnumd5.h ppfbinstream.h \
+ rawstream.h ppfnametag.h ndatablock.h anydataobj.h randr48.h objfio.h \
+ randinterf.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  randr48.cc
  
 $(SOPHYAOBJP)rawstream.o: rawstream.cc sopnamsp.h rawstream.h \
-  $(SOPHYAINCP)machdefs.h \
-  pexceptions.h
+ $(SOPHYAINCP)machdefs.h pexceptions.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  rawstream.cc
  
 $(SOPHYAOBJP)sophyainit.o: sophyainit.cc sopnamsp.h \
-  $(SOPHYAINCP)machdefs.h \
-  sophyainit.h pexceptions.h ppersist.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h fiondblock.h ndatablock.h anydataobj.h \
-  dvlist.h objfio.h mutyv.h timestamp.h randr48.h randinterf.h randfmt.h \
-  fiosegdb.h segdatablock.h thsafeop.h ppftpointerio.h ppfwrapstlv.h \
-  sversion.h
+ $(SOPHYAINCP)machdefs.h sophyainit.h \
+ pexceptions.h ppersist.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h fiondblock.h ndatablock.h anydataobj.h dvlist.h objfio.h \
+ mutyv.h timestamp.h randr48.h randinterf.h randfmt.h randtmt32.h randtmt64.h fiosegdb.h \
+ segdatablock.h thsafeop.h ppftpointerio.h ppfwrapstlv.h sversion.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  sophyainit.cc
  
 $(SOPHYAOBJP)stsrand.o: stsrand.cc stsrand.h \
-  $(SOPHYAINCP)machdefs.h \
-  objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h ppfbinstream.h \
-  rawstream.h ppfnametag.h ndatablock.h thsafeop.h fiondblock.h
+ $(SOPHYAINCP)machdefs.h objfio.h anydataobj.h \
+ ppersist.h pexceptions.h gnumd5.h ppfbinstream.h rawstream.h \
+ ppfnametag.h ndatablock.h thsafeop.h fiondblock.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  stsrand.cc
  
-$(SOPHYAOBJP)timestamp.o: timestamp.cc \
-  $(SOPHYAINCP)machdefs.h \
-  timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
-  ppfbinstream.h rawstream.h ppfnametag.h
+$(SOPHYAOBJP)timestamp.o: timestamp.cc $(SOPHYAINCP)machdefs.h \
+ timestamp.h objfio.h anydataobj.h ppersist.h pexceptions.h gnumd5.h \
+ ppfbinstream.h rawstream.h ppfnametag.h
 	$(CXXCOMPILE) $(CXXTEMPFLG) -o $@  timestamp.cc
  
@@ -107,7 +114,12 @@
 	$(CCOMPILE) -o $@  dSFMT.c
  
-$(SOPHYAOBJP)gnumd5.o: gnumd5.c \
-  $(SOPHYAINCP)machdefs.h \
-  bithelp.h gnumd5.h
+$(SOPHYAOBJP)gnumd5.o: gnumd5.c $(SOPHYAINCP)machdefs.h \
+ bithelp.h gnumd5.h
 	$(CCOMPILE) -o $@  gnumd5.c
  
+$(SOPHYAOBJP)tinymt32.o: tinymt32.c tinymt32.h
+	$(CCOMPILE) -o $@  tinymt32.c
+ 
+$(SOPHYAOBJP)tinymt64.o: tinymt64.c tinymt64.h
+	$(CCOMPILE) -o $@  tinymt64.c
+ 
Index: trunk/SophyaLib/BaseTools/sophyainit.cc
===================================================================
--- trunk/SophyaLib/BaseTools/sophyainit.cc	(revision 4018)
+++ trunk/SophyaLib/BaseTools/sophyainit.cc	(revision 4019)
@@ -17,4 +17,6 @@
 #include "randr48.h"
 #include "randfmt.h"
+#include "randtmt32.h"
+#include "randtmt64.h"
 
 #include "fiosegdb.h" 
@@ -123,4 +125,8 @@
   PPRegister(ObjFileIO<FMTRandGen>);
   DObjRegister(ObjFileIO<FMTRandGen>, FMTRandGen);
+  PPRegister(ObjFileIO<TinyMT32RandGen>);
+  DObjRegister(ObjFileIO<TinyMT32RandGen>, TinyMT32RandGen);
+  PPRegister(ObjFileIO<TinyMT64RandGen>);
+  DObjRegister(ObjFileIO<TinyMT64RandGen>, TinyMT64RandGen);
 
   // Enregistrement des handlers PPF pour les SegDataBlock<T> 
Index: trunk/SophyaLib/BaseTools/tinymt32.c
===================================================================
--- trunk/SophyaLib/BaseTools/tinymt32.c	(revision 4019)
+++ trunk/SophyaLib/BaseTools/tinymt32.c	(revision 4019)
@@ -0,0 +1,140 @@
+/**
+ * @file tinymt32.c
+ *
+ * @brief Tiny Mersenne Twister only 127 bit internal state
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (The University of Tokyo)
+ *
+ * Copyright (C) 2011 Mutsuo Saito, Makoto Matsumoto,
+ * Hiroshima University and The University of Tokyo.
+ * All rights reserved.
+ *
+ * The 3-clause BSD License is applied to this software, see
+ * LICENSE.txt
+ */
+#include "tinymt32.h"
+#define MIN_LOOP 8
+#define PRE_LOOP 8
+
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param x 32-bit integer
+ * @return 32-bit integer
+ */
+static uint32_t ini_func1(uint32_t x) {
+    return (x ^ (x >> 27)) * (uint32_t)1664525UL;
+}
+
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param x 32-bit integer
+ * @return 32-bit integer
+ */
+static uint32_t ini_func2(uint32_t x) {
+    return (x ^ (x >> 27)) * (uint32_t)1566083941UL;
+}
+
+/**
+ * This function certificate the period of 2^127-1.
+ * @param random tinymt state vector.
+ */
+static void period_certification(tinymt32_t * random) {
+    if ((random->status[0] & TINYMT32_MASK) == 0 &&
+	random->status[1] == 0 &&
+	random->status[2] == 0 &&
+	random->status[3] == 0) {
+	random->status[0] = 'T';
+	random->status[1] = 'I';
+	random->status[2] = 'N';
+	random->status[3] = 'Y';
+    }
+}
+
+/**
+ * This function initializes the internal state array with a 32-bit
+ * unsigned integer seed.
+ * @param random tinymt state vector.
+ * @param seed a 32-bit unsigned integer used as a seed.
+ */
+void tinymt32_init(tinymt32_t * random, uint32_t seed) {
+    int i;
+    random->status[0] = seed;
+    random->status[1] = random->mat1;
+    random->status[2] = random->mat2;
+    random->status[3] = random->tmat;
+    for (i = 1; i < MIN_LOOP; i++) {
+	random->status[i & 3] ^= i + UINT32_C(1812433253)
+	    * (random->status[(i - 1) & 3]
+	       ^ (random->status[(i - 1) & 3] >> 30));
+    }
+    period_certification(random);
+    for (i = 0; i < PRE_LOOP; i++) {
+	tinymt32_next_state(random);
+    }
+}
+
+/**
+ * This function initializes the internal state array,
+ * with an array of 32-bit unsigned integers used as seeds
+ * @param random tinymt state vector.
+ * @param init_key the array of 32-bit integers, used as a seed.
+ * @param key_length the length of init_key.
+ */
+void tinymt32_init_by_array(tinymt32_t * random, uint32_t init_key[],
+			    int key_length) {
+    const int lag = 1;
+    const int mid = 1;
+    const int size = 4;
+    int i, j;
+    int count;
+    uint32_t r;
+    uint32_t * st = &random->status[0];
+
+    st[0] = 0;
+    st[1] = random->mat1;
+    st[2] = random->mat2;
+    st[3] = random->tmat;
+    if (key_length + 1 > MIN_LOOP) {
+	count = key_length + 1;
+    } else {
+	count = MIN_LOOP;
+    }
+    r = ini_func1(st[0] ^ st[mid % size]
+		  ^ st[(size - 1) % size]);
+    st[mid % size] += r;
+    r += key_length;
+    st[(mid + lag) % size] += r;
+    st[0] = r;
+    count--;
+    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
+	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
+	st[(i + mid) % size] += r;
+	r += init_key[j] + i;
+	st[(i + mid + lag) % size] += r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    for (; j < count; j++) {
+	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
+	st[(i + mid) % size] += r;
+	r += i;
+	st[(i + mid + lag) % size] += r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    for (j = 0; j < size; j++) {
+	r = ini_func2(st[i] + st[(i + mid) % size] + st[(i + size - 1) % size]);
+	st[(i + mid) % size] ^= r;
+	r -= i;
+	st[(i + mid + lag) % size] ^= r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    period_certification(random);
+    for (i = 0; i < PRE_LOOP; i++) {
+	tinymt32_next_state(random);
+    }
+}
Index: trunk/SophyaLib/BaseTools/tinymt32.h
===================================================================
--- trunk/SophyaLib/BaseTools/tinymt32.h	(revision 4019)
+++ trunk/SophyaLib/BaseTools/tinymt32.h	(revision 4019)
@@ -0,0 +1,248 @@
+#ifndef TINYMT32_H
+#define TINYMT32_H
+/**
+ * @file tinymt32.h
+ *
+ * @brief Tiny Mersenne Twister only 127 bit internal state
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (University of Tokyo)
+ *
+ * Copyright (C) 2011 Mutsuo Saito, Makoto Matsumoto,
+ * Hiroshima University and The University of Tokyo.
+ * All rights reserved.
+ *
+ * The 3-clause BSD License is applied to this software, see
+ * LICENSE.txt
+ */
+
+#include <stdint.h>
+#include <inttypes.h>
+
+#define TINYMT32_MEXP 127
+#define TINYMT32_SH0 1
+#define TINYMT32_SH1 10
+#define TINYMT32_SH8 8
+#define TINYMT32_MASK UINT32_C(0x7fffffff)
+#define TINYMT32_MUL (1.0f / 4294967296.0f)
+
+/**
+ * tinymt32 internal state vector and parameters
+ */
+struct TINYMT32_T {
+    uint32_t status[4];
+    uint32_t mat1;
+    uint32_t mat2;
+    uint32_t tmat;
+};
+
+typedef struct TINYMT32_T tinymt32_t;
+
+/* --- Ajout par cmv / Compilation C++ --- */ 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void tinymt32_init(tinymt32_t * random, uint32_t seed);
+void tinymt32_init_by_array(tinymt32_t * random, uint32_t init_key[],
+			    int key_length);
+
+/* --- Ajout par cmv / Compilation C++ --- */ 
+#ifdef __cplusplus
+}
+#endif
+
+#if defined(__GNUC__)
+/**
+ * This function always returns 127
+ * @param random not used
+ * @return always 127
+ */
+inline static int tinymt32_get_mexp(
+    tinymt32_t * random  __attribute__((unused))) {
+    return TINYMT32_MEXP;
+}
+#else
+inline static int tinymt32_get_mexp(tinymt32_t * random) {
+    return TINYMT32_MEXP;
+}
+#endif
+
+/**
+ * This function changes internal state of tinymt32.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ */
+inline static void tinymt32_next_state(tinymt32_t * random) {
+    uint32_t x;
+    uint32_t y;
+
+    y = random->status[3];
+    x = (random->status[0] & TINYMT32_MASK)
+	^ random->status[1]
+	^ random->status[2];
+    x ^= (x << TINYMT32_SH0);
+    y ^= (y >> TINYMT32_SH0) ^ x;
+    random->status[0] = random->status[1];
+    random->status[1] = random->status[2];
+    random->status[2] = x ^ (y << TINYMT32_SH1);
+    random->status[3] = y;
+    random->status[1] ^= -((int32_t)(y & 1)) & random->mat1;
+    random->status[2] ^= -((int32_t)(y & 1)) & random->mat2;
+}
+
+/**
+ * This function outputs 32-bit unsigned integer from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return 32-bit unsigned pseudorandom number
+ */
+inline static uint32_t tinymt32_temper(tinymt32_t * random) {
+    uint32_t t0, t1;
+    t0 = random->status[3];
+#if defined(LINEARITY_CHECK)
+    t1 = random->status[0]
+	^ (random->status[2] >> TINYMT32_SH8);
+#else
+    t1 = random->status[0]
+	+ (random->status[2] >> TINYMT32_SH8);
+#endif
+    t0 ^= t1;
+    t0 ^= -((int32_t)(t1 & 1)) & random->tmat;
+    return t0;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 <= r < 2.0)
+ */
+inline static float tinymt32_temper_conv(tinymt32_t * random) {
+    uint32_t t0, t1;
+    union {
+	uint32_t u;
+	float f;
+    } conv;
+
+    t0 = random->status[3];
+#if defined(LINEARITY_CHECK)
+    t1 = random->status[0]
+	^ (random->status[2] >> TINYMT32_SH8);
+#else
+    t1 = random->status[0]
+	+ (random->status[2] >> TINYMT32_SH8);
+#endif
+    t0 ^= t1;
+    conv.u = ((t0 ^ (-((int32_t)(t1 & 1)) & random->tmat)) >> 9)
+	      | UINT32_C(0x3f800000);
+    return conv.f;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 < r < 2.0)
+ */
+inline static float tinymt32_temper_conv_open(tinymt32_t * random) {
+    uint32_t t0, t1;
+    union {
+	uint32_t u;
+	float f;
+    } conv;
+
+    t0 = random->status[3];
+#if defined(LINEARITY_CHECK)
+    t1 = random->status[0]
+	^ (random->status[2] >> TINYMT32_SH8);
+#else
+    t1 = random->status[0]
+	+ (random->status[2] >> TINYMT32_SH8);
+#endif
+    t0 ^= t1;
+    conv.u = ((t0 ^ (-((int32_t)(t1 & 1)) & random->tmat)) >> 9)
+	      | UINT32_C(0x3f800001);
+    return conv.f;
+}
+
+/**
+ * This function outputs 32-bit unsigned integer from internal state.
+ * @param random tinymt internal status
+ * @return 32-bit unsigned integer r (0 <= r < 2^32)
+ */
+inline static uint32_t tinymt32_generate_uint32(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using multiplying by 1 / 2^32.
+ * floating point multiplication is faster than using union trick in
+ * my Intel CPU.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 <= r < 1.0)
+ */
+inline static float tinymt32_generate_float(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper(random) * TINYMT32_MUL;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 <= r < 2.0)
+ */
+inline static float tinymt32_generate_float12(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper_conv(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 <= r < 1.0)
+ */
+inline static float tinymt32_generate_float01(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper_conv(random) - 1.0f;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function may return 1.0 and never returns 0.0.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 < r <= 1.0)
+ */
+inline static float tinymt32_generate_floatOC(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return 1.0f - tinymt32_generate_float(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function returns neither 0.0 nor 1.0.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 < r < 0.0)
+ */
+inline static float tinymt32_generate_floatOO(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper_conv_open(random) - 1.0f;
+}
+
+/**
+ * This function outputs double precision floating point number from
+ * internal state. The returned value has 32-bit precision.
+ * In other words, this function makes one double precision floating point
+ * number from one 32-bit unsigned integer.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 < r < 2.0)
+ */
+inline static double tinymt32_generate_32double(tinymt32_t * random) {
+    tinymt32_next_state(random);
+    return tinymt32_temper(random) * (1.0 / 4294967296.0);
+}
+#endif
Index: trunk/SophyaLib/BaseTools/tinymt64.c
===================================================================
--- trunk/SophyaLib/BaseTools/tinymt64.c	(revision 4019)
+++ trunk/SophyaLib/BaseTools/tinymt64.c	(revision 4019)
@@ -0,0 +1,130 @@
+/**
+ * @file tinymt64.c
+ *
+ * @brief 64-bit Tiny Mersenne Twister only 127 bit internal state
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (The University of Tokyo)
+ *
+ * Copyright (C) 2011 Mutsuo Saito, Makoto Matsumoto,
+ * Hiroshima University and The University of Tokyo.
+ * All rights reserved.
+ *
+ * The 3-clause BSD License is applied to this software, see
+ * LICENSE.txt
+ */
+#include "tinymt64.h"
+
+#define MIN_LOOP 8
+
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param[in] x 64-bit integer
+ * @return 64-bit integer
+ */
+static uint64_t ini_func1(uint64_t x) {
+    return (x ^ (x >> 59)) * UINT64_C(2173292883993);
+}
+
+/**
+ * This function represents a function used in the initialization
+ * by init_by_array
+ * @param[in] x 64-bit integer
+ * @return 64-bit integer
+ */
+static uint64_t ini_func2(uint64_t x) {
+    return (x ^ (x >> 59)) * UINT64_C(58885565329898161);
+}
+
+/**
+ * This function certificate the period of 2^127-1.
+ * @param random tinymt state vector.
+ */
+static void period_certification(tinymt64_t * random) {
+    if ((random->status[0] & TINYMT64_MASK) == 0 &&
+	random->status[1] == 0) {
+	random->status[0] = 'T';
+	random->status[1] = 'M';
+    }
+}
+
+/**
+ * This function initializes the internal state array with a 64-bit
+ * unsigned integer seed.
+ * @param random tinymt state vector.
+ * @param seed a 64-bit unsigned integer used as a seed.
+ */
+void tinymt64_init(tinymt64_t * random, uint64_t seed) {
+    int i;
+    random->status[0] = seed ^ ((uint64_t)random->mat1 << 32);
+    random->status[1] = random->mat2 ^ random->tmat;
+    for (i = 1; i < MIN_LOOP; i++) {
+	random->status[i & 1] ^= i + UINT64_C(6364136223846793005)
+	    * (random->status[(i - 1) & 1]
+	       ^ (random->status[(i - 1) & 1] >> 62));
+    }
+    period_certification(random);
+}
+
+/**
+ * This function initializes the internal state array,
+ * with an array of 64-bit unsigned integers used as seeds
+ * @param random tinymt state vector.
+ * @param init_key the array of 64-bit integers, used as a seed.
+ * @param key_length the length of init_key.
+ */
+void tinymt64_init_by_array(tinymt64_t * random, const uint64_t init_key[],
+			    int key_length) {
+    const int lag = 1;
+    const int mid = 1;
+    const int size = 4;
+    int i, j;
+    int count;
+    uint64_t r;
+    uint64_t st[4];
+
+    st[0] = 0;
+    st[1] = random->mat1;
+    st[2] = random->mat2;
+    st[3] = random->tmat;
+    if (key_length + 1 > MIN_LOOP) {
+	count = key_length + 1;
+    } else {
+	count = MIN_LOOP;
+    }
+    r = ini_func1(st[0] ^ st[mid % size]
+		  ^ st[(size - 1) % size]);
+    st[mid % size] += r;
+    r += key_length;
+    st[(mid + lag) % size] += r;
+    st[0] = r;
+    count--;
+    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
+	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
+	st[(i + mid) % size] += r;
+	r += init_key[j] + i;
+	st[(i + mid + lag) % size] += r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    for (; j < count; j++) {
+	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
+	st[(i + mid) % size] += r;
+	r += i;
+	st[(i + mid + lag) % size] += r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    for (j = 0; j < size; j++) {
+	r = ini_func2(st[i] + st[(i + mid) % size] + st[(i + size - 1) % size]);
+	st[(i + mid) % size] ^= r;
+	r -= i;
+	st[(i + mid + lag) % size] ^= r;
+	st[i] = r;
+	i = (i + 1) % size;
+    }
+    random->status[0] = st[0] ^ st[1];
+    random->status[1] = st[2] ^ st[3];
+    period_certification(random);
+}
Index: trunk/SophyaLib/BaseTools/tinymt64.h
===================================================================
--- trunk/SophyaLib/BaseTools/tinymt64.h	(revision 4019)
+++ trunk/SophyaLib/BaseTools/tinymt64.h	(revision 4019)
@@ -0,0 +1,220 @@
+#ifndef TINYMT64_H
+#define TINYMT64_H
+/**
+ * @file tinymt64.h
+ *
+ * @brief Tiny Mersenne Twister only 127 bit internal state
+ *
+ * @author Mutsuo Saito (Hiroshima University)
+ * @author Makoto Matsumoto (The University of Tokyo)
+ *
+ * Copyright (C) 2011 Mutsuo Saito, Makoto Matsumoto,
+ * Hiroshima University and The University of Tokyo.
+ * All rights reserved.
+ *
+ * The 3-clause BSD License is applied to this software, see
+ * LICENSE.txt
+ */
+
+#include <stdint.h>
+#include <inttypes.h>
+
+#define TINYMT64_MEXP 127
+#define TINYMT64_SH0 12
+#define TINYMT64_SH1 11
+#define TINYMT64_SH8 8
+#define TINYMT64_MASK UINT64_C(0x7fffffffffffffff)
+#define TINYMT64_MUL (1.0 / 18446744073709551616.0)
+
+/*
+ * tinymt64 internal state vector and parameters
+ */
+struct TINYMT64_T {
+    uint64_t status[2];
+    uint32_t mat1;
+    uint32_t mat2;
+    uint64_t tmat;
+};
+
+typedef struct TINYMT64_T tinymt64_t;
+
+/* --- Ajout par cmv / Compilation C++ --- */ 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void tinymt64_init(tinymt64_t * random, uint64_t seed);
+void tinymt64_init_by_array(tinymt64_t * random, const uint64_t init_key[],
+			    int key_length);
+
+/* --- Ajout par cmv / Compilation C++ --- */ 
+#ifdef __cplusplus
+}
+#endif
+
+#if defined(__GNUC__)
+/**
+ * This function always returns 127
+ * @param random not used
+ * @return always 127
+ */
+inline static int tinymt64_get_mexp(
+    tinymt64_t * random  __attribute__((unused))) {
+    return TINYMT64_MEXP;
+}
+#else
+inline static int tinymt64_get_mexp(tinymt64_t * random) {
+    return TINYMT64_MEXP;
+}
+#endif
+
+/**
+ * This function changes internal state of tinymt64.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ */
+inline static void tinymt64_next_state(tinymt64_t * random) {
+    uint64_t x;
+
+    random->status[0] &= TINYMT64_MASK;
+    x = random->status[0] ^ random->status[1];
+    x ^= x << TINYMT64_SH0;
+    x ^= x >> 32;
+    x ^= x << 32;
+    x ^= x << TINYMT64_SH1;
+    random->status[0] = random->status[1];
+    random->status[1] = x;
+    random->status[0] ^= -((int64_t)(x & 1)) & random->mat1;
+    random->status[1] ^= -((int64_t)(x & 1)) & (((uint64_t)random->mat2) << 32);
+}
+
+/**
+ * This function outputs 64-bit unsigned integer from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return 64-bit unsigned pseudorandom number
+ */
+inline static uint64_t tinymt64_temper(tinymt64_t * random) {
+    uint64_t x;
+#if defined(LINEARITY_CHECK)
+    x = random->status[0] ^ random->status[1];
+#else
+    x = random->status[0] + random->status[1];
+#endif
+    x ^= random->status[0] >> TINYMT64_SH8;
+    x ^= -((int64_t)(x & 1)) & random->tmat;
+    return x;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 <= r < 2.0)
+ */
+inline static double tinymt64_temper_conv(tinymt64_t * random) {
+    uint64_t x;
+    union {
+	uint64_t u;
+	double d;
+    } conv;
+#if defined(LINEARITY_CHECK)
+    x = random->status[0] ^ random->status[1];
+#else
+    x = random->status[0] + random->status[1];
+#endif
+    x ^= random->status[0] >> TINYMT64_SH8;
+    conv.u = ((x ^ (-((int64_t)(x & 1)) & random->tmat)) >> 12)
+	| UINT64_C(0x3ff0000000000000);
+    return conv.d;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * Users should not call this function directly.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 < r < 2.0)
+ */
+inline static double tinymt64_temper_conv_open(tinymt64_t * random) {
+    uint64_t x;
+    union {
+	uint64_t u;
+	double d;
+    } conv;
+#if defined(LINEARITY_CHECK)
+    x = random->status[0] ^ random->status[1];
+#else
+    x = random->status[0] + random->status[1];
+#endif
+    x ^= random->status[0] >> TINYMT64_SH8;
+    conv.u = ((x ^ (-((int64_t)(x & 1)) & random->tmat)) >> 12)
+	| UINT64_C(0x3ff0000000000001);
+    return conv.d;
+}
+
+/**
+ * This function outputs 64-bit unsigned integer from internal state.
+ * @param random tinymt internal status
+ * @return 64-bit unsigned integer r (0 <= r < 2^64)
+ */
+inline static uint64_t tinymt64_generate_uint64(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return tinymt64_temper(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using multiplying by 1 / 2^64.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 <= r < 1.0)
+ */
+inline static double tinymt64_generate_double(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return tinymt64_temper(random) * TINYMT64_MUL;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 <= r < 1.0)
+ */
+inline static double tinymt64_generate_double01(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return tinymt64_temper_conv(random) - 1.0;
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (1.0 <= r < 2.0)
+ */
+inline static double tinymt64_generate_double12(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return tinymt64_temper_conv(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 < r <= 1.0)
+ */
+inline static double tinymt64_generate_doubleOC(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return 2.0 - tinymt64_temper_conv(random);
+}
+
+/**
+ * This function outputs floating point number from internal state.
+ * This function is implemented using union trick.
+ * @param random tinymt internal status
+ * @return floating point number r (0.0 < r < 1.0)
+ */
+inline static double tinymt64_generate_doubleOO(tinymt64_t * random) {
+    tinymt64_next_state(random);
+    return tinymt64_temper_conv_open(random) - 1.0;
+}
+
+#endif
