[mlpack] 114/324: arma::sign() doesn't exist in Armadillo pre-3.920.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:22:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 19029a04f8259e677633aaca7fcddb2cda68d3ea
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Thu Jul 3 13:55:23 2014 +0000

    arma::sign() doesn't exist in Armadillo pre-3.920.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16752 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/core/dists/laplace_distribution.hpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/core/dists/laplace_distribution.hpp b/src/mlpack/core/dists/laplace_distribution.hpp
index 5757f8e..63aa7f4 100644
--- a/src/mlpack/core/dists/laplace_distribution.hpp
+++ b/src/mlpack/core/dists/laplace_distribution.hpp
@@ -89,8 +89,19 @@ class LaplaceDistribution
     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;
   }
 
   /**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list