Browse Source

Replaced boost random with C++-11 alternative.

enhancement_3
T-bone 8 years ago
parent
commit
5c7dffaa3b
3 changed files with 14 additions and 6 deletions
  1. 2
    2
      CMakeLists.txt
  2. 3
    2
      LemmaCore/include/TEMReceiver.h
  3. 9
    2
      LemmaCore/src/TEMReceiver.cpp

+ 2
- 2
CMakeLists.txt View File

53
 ELSE() 
53
 ELSE() 
54
 # Stable Eigen, requires manual updating when new releases, but lighter weight.  
54
 # Stable Eigen, requires manual updating when new releases, but lighter weight.  
55
 ExternalProject_Add(EIGEN
55
 ExternalProject_Add(EIGEN
56
-	URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
57
-    #URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
56
+    #URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
57
+    URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
58
     PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
58
     PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
59
     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
59
     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
60
 )
60
 )

+ 3
- 2
LemmaCore/include/TEMReceiver.h View File

22
 
22
 
23
 #include "receiverpoints.h"
23
 #include "receiverpoints.h"
24
 
24
 
25
-#include <boost/random.hpp>
26
-#include <boost/random/normal_distribution.hpp>
25
+//#include <boost/random.hpp>
26
+//#include <boost/random/normal_distribution.hpp>
27
+#include <random>
27
 
28
 
28
 namespace Lemma {
29
 namespace Lemma {
29
 
30
 

+ 9
- 2
LemmaCore/src/TEMReceiver.cpp View File

185
     //      Method:  SampleNoise
185
     //      Method:  SampleNoise
186
     //--------------------------------------------------------------------------------------
186
     //--------------------------------------------------------------------------------------
187
     VectorXr TEMReceiver::SampleNoise (  ) {
187
     VectorXr TEMReceiver::SampleNoise (  ) {
188
-        // Consider making these static?
188
+        
189
+	/* we have C++-11 now! No Boost! 
189
         boost::mt19937 rng(time(0));
190
         boost::mt19937 rng(time(0));
190
         boost::normal_distribution<> nd(0.0, 1.0);
191
         boost::normal_distribution<> nd(0.0, 1.0);
191
         boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng, nd);
192
         boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng, nd);
193
+	*/
194
+
195
+        std::random_device rd;
196
+        std::mt19937 gen(rd()); 
197
+        std::normal_distribution<> d(0.0, 1.00);
192
 
198
 
193
         VectorXr noise = VectorXr::Zero( windowCentres.size() );
199
         VectorXr noise = VectorXr::Zero( windowCentres.size() );
194
         for (int ii=0; ii<windowCentres.size(); ++ii) {
200
         for (int ii=0; ii<windowCentres.size(); ++ii) {
195
-            noise(ii) = var_nor();
201
+            //noise(ii) = var_nor(); // old boost way
202
+            noise(ii) = d(gen);
196
         }
203
         }
197
         return noise.array() * noiseSTD.array();
204
         return noise.array() * noiseSTD.array();
198
     }		// -----  end of method TEMReceiver::SampleNoise  -----
205
     }		// -----  end of method TEMReceiver::SampleNoise  -----

Loading…
Cancel
Save