[mlpack-svn] r12467 - mlpack/trunk/src/mlpack/core/math
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Apr 19 13:56:38 EDT 2012
Author: rcurtin
Date: 2012-04-19 13:56:38 -0400 (Thu, 19 Apr 2012)
New Revision: 12467
Modified:
mlpack/trunk/src/mlpack/core/math/random.cpp
mlpack/trunk/src/mlpack/core/math/random.hpp
Log:
Fix preprocessor ifs for Boost <= 1.39 Random API changes.
Modified: mlpack/trunk/src/mlpack/core/math/random.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/random.cpp 2012-04-19 17:32:51 UTC (rev 12466)
+++ mlpack/trunk/src/mlpack/core/math/random.cpp 2012-04-19 17:56:38 UTC (rev 12467)
@@ -25,7 +25,7 @@
boost::uniform_01<> randUniformDist;
#else
// Pre-1.39 Boost.Random did not give default template parameter values.
- boost::uniform_01<double, double> randUniformDist;
+ boost::uniform_01<boost::mt19937, double> randUniformDist(randGen);
#endif
// Global normal distribution.
Modified: mlpack/trunk/src/mlpack/core/math/random.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/random.hpp 2012-04-19 17:32:51 UTC (rev 12466)
+++ mlpack/trunk/src/mlpack/core/math/random.hpp 2012-04-19 17:56:38 UTC (rev 12467)
@@ -28,8 +28,15 @@
#else
// Global random object.
extern boost::mt19937 randGen;
- // Global uniform distribution.
- extern boost::uniform_01<> randUniformDist;
+
+ #if BOOST_VERSION >= 103900
+ // Global uniform distribution.
+ extern boost::uniform_01<> randUniformDist;
+ #else
+ // Pre-1.39 Boost.Random did not give default template parameter values.
+ extern boost::uniform_01<boost::mt19937, double> randUniformDist;
+ #endif
+
// Global normal distribution.
extern boost::normal_distribution<> randNormalDist;
#endif
@@ -52,7 +59,13 @@
*/
inline double Random()
{
+#if BOOST_VERSION >= 103900
return randUniformDist(randGen);
+#else
+ // Before Boost 1.39, we did not give the random object when we wanted a
+ // random number; that gets given at construction time.
+ return randUniformDist();
+#endif
}
/**
More information about the mlpack-svn
mailing list