[mlpack-git] master, mlpack-1.0.x: arma::sign() doesn't exist in Armadillo pre-3.920. (d35bd6c)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:50:54 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit d35bd6c364ecce399927cec83278397eda48648b
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Jul 3 13:55:23 2014 +0000
arma::sign() doesn't exist in Armadillo pre-3.920.
>---------------------------------------------------------------
d35bd6c364ecce399927cec83278397eda48648b
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;
}
/**
More information about the mlpack-git
mailing list