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,8 +53,8 @@ ExternalProject_Add(EIGEN
53 53
 ELSE() 
54 54
 # Stable Eigen, requires manual updating when new releases, but lighter weight.  
55 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 58
     PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
59 59
     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
60 60
 )

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

@@ -22,8 +22,9 @@
22 22
 
23 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 29
 namespace Lemma {
29 30
 

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

@@ -185,14 +185,21 @@ namespace Lemma {
185 185
     //      Method:  SampleNoise
186 186
     //--------------------------------------------------------------------------------------
187 187
     VectorXr TEMReceiver::SampleNoise (  ) {
188
-        // Consider making these static?
188
+        
189
+	/* we have C++-11 now! No Boost! 
189 190
         boost::mt19937 rng(time(0));
190 191
         boost::normal_distribution<> nd(0.0, 1.0);
191 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 199
         VectorXr noise = VectorXr::Zero( windowCentres.size() );
194 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 204
         return noise.array() * noiseSTD.array();
198 205
     }		// -----  end of method TEMReceiver::SampleNoise  -----

Loading…
Cancel
Save