[mlpack-svn] r16752 - mlpack/trunk/src/mlpack/core/dists

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Jul 3 09:55:23 EDT 2014


Author: rcurtin
Date: Thu Jul  3 09:55:23 2014
New Revision: 16752

Log:
arma::sign() doesn't exist in Armadillo pre-3.920.


Modified:
   mlpack/trunk/src/mlpack/core/dists/laplace_distribution.hpp

Modified: mlpack/trunk/src/mlpack/core/dists/laplace_distribution.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/dists/laplace_distribution.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/dists/laplace_distribution.hpp	Thu Jul  3 09:55:23 2014
@@ -89,8 +89,19 @@
     result.randu();
 
     // Convert from uniform distribution to Laplace distribution.
-    return mean - scale * arma::sign(result) % arma::log(1 - 2.0 * (result -
-        0.5));
+    // arma::sign() does not exist in Armadillo < 3.920 so we have to do this
+    // elementwise.
+    for (size_t i = 0; i < result.n_elem; ++i)
+    {
+      if (result[i] < 0)
+        result[i] = mean[i] + scale * result[i] * std::log(1 + 2.0 * (result[i]
+            - 0.5));
+      else
+        result[i] = mean[i] - scale * result[i] * std::log(1 - 2.0 * (result[i]
+            - 0.5));
+    }
+
+    return result;
   }
 
   /**



More information about the mlpack-svn mailing list