]> git.donarmstrong.com Git - rsem.git/commitdiff
Modified the use of uniform_01
authorBo Li <bli@cs.wisc.edu>
Fri, 6 Jun 2014 10:41:46 +0000 (05:41 -0500)
committerBo Li <bli@cs.wisc.edu>
Fri, 6 Jun 2014 10:41:46 +0000 (05:41 -0500)
EM.cpp
Gibbs.cpp
sampling.h
simul.h

diff --git a/EM.cpp b/EM.cpp
index 4bda1d8ce8ae7431f7251724fee856aa37b5650f..7016b8944def26003c755697627019fe0dd0d6ea 100644 (file)
--- a/EM.cpp
+++ b/EM.cpp
@@ -506,7 +506,9 @@ void EM() {
                        READ_INT_TYPE local_N;
                        HIT_INT_TYPE fr, to, len, id;
                        vector<double> arr;
                        READ_INT_TYPE local_N;
                        HIT_INT_TYPE fr, to, len, id;
                        vector<double> arr;
-                       uniform01 rg(engine_type(hasSeed ? seed : time(NULL)));
+                       engine_type engine(hasSeed ? seed : time(NULL));
+                       uniform_01_dist uniform_01;
+                       uniform_01_generator rg(engine, uniform_01);
 
                        if (verbose) cout<< "Begin to sample reads from their posteriors."<< endl;
                        for (int i = 0; i < nThreads; i++) {
 
                        if (verbose) cout<< "Begin to sample reads from their posteriors."<< endl;
                        for (int i = 0; i < nThreads; i++) {
index 7215c104244a3954664f6a2efd7cffac81f42905..d5e0b9c49634e29c9a4f2b5ed2a5c74026f5642f 100644 (file)
--- a/Gibbs.cpp
+++ b/Gibbs.cpp
@@ -229,7 +229,7 @@ void* Gibbs(void* arg) {
        vector<int> z, counts;
        vector<double> arr;
 
        vector<int> z, counts;
        vector<double> arr;
 
-       uniform01 rg(*params->engine);
+       uniform_01_generator rg(*params->engine, uniform_01_dist());
 
        // generate initial state
        sampleTheta(*params->engine, theta);
 
        // generate initial state
        sampleTheta(*params->engine, theta);
index 8f80b72eca8d4982731d15a366100b5c68563ed3..7e445cf8995e871183b5b18b66ee23b8efd91b8e 100644 (file)
 #include "boost/random.hpp"
 
 typedef unsigned int seedType;
 #include "boost/random.hpp"
 
 typedef unsigned int seedType;
-typedef boost::mt19937 engine_type;
-typedef boost::gamma_distribution<> gamma_dist;
-typedef boost::uniform_01<engine_type> uniform01;
-typedef boost::variate_generator<engine_type&, gamma_dist> gamma_generator;
+typedef boost::random::mt19937 engine_type;
+typedef boost::random::uniform_01<> uniform_01_dist;
+typedef boost::random::gamma_distribution<> gamma_dist;
+typedef boost::random::variate_generator<engine_type&, uniform_01_dist> uniform_01_generator;
+typedef boost::random::variate_generator<engine_type&, gamma_dist> gamma_generator;
 
 class engineFactory {
 public:
 
 class engineFactory {
 public:
@@ -46,7 +47,7 @@ engine_type* engineFactory::seedEngine = NULL;
 // interval : [,)
 // random number should be in [0, arr[len - 1])
 // If by chance arr[len - 1] == 0.0, one possibility is to sample uniformly from 0...len-1
 // interval : [,)
 // random number should be in [0, arr[len - 1])
 // If by chance arr[len - 1] == 0.0, one possibility is to sample uniformly from 0...len-1
-int sample(uniform01& rg, std::vector<double>& arr, int len) {
+int sample(uniform_01_generator& rg, std::vector<double>& arr, int len) {
   int l, r, mid;
   double prb = rg() * arr[len - 1];
 
   int l, r, mid;
   double prb = rg() * arr[len - 1];
 
diff --git a/simul.h b/simul.h
index 07c1c65ec8d243b147bc70150b3e50fc381824c4..b62132a66a636115c3484073d7277bc5898d0eeb 100644 (file)
--- a/simul.h
+++ b/simul.h
@@ -8,8 +8,8 @@
 class simul {
 public:
 
 class simul {
 public:
 
      simul(unsigned int seed) : rg(boost::mt19937(seed)) {
-       }
simul(unsigned int seed) : engine(seed), rg(engine, boost::random::uniform_01<>()) {
+  }
 
        // interval : [,)
        // random number should be in [0, arr[len - 1])
 
        // interval : [,)
        // random number should be in [0, arr[len - 1])
@@ -35,7 +35,8 @@ public:
        double random() { return rg(); };
 
 private:
        double random() { return rg(); };
 
 private:
-       boost::uniform_01<boost::mt19937> rg;
+       boost::random::mt19937 engine;
+       boost::random::variate_generator<boost::random::mt19937&, boost::random::uniform_01<> > rg;
 };
 
 #endif /* SIMUL_H_ */
 };
 
 #endif /* SIMUL_H_ */