[mlpack-git] master: Convert std::pow usage to shifts. (d97e651)

gitdub at mlpack.org gitdub at mlpack.org
Thu Sep 29 12:03:17 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/9ef7339d40550a974b3939e9fcb966fac2c09065...ebdb5abeaa3fd621a06ae663862bb72df76d2b40

>---------------------------------------------------------------

commit d97e6516be74d58f1a1388dde9abae3f57dd9819
Author: Ryan Curtin <ryan at ratml.org>
Date:   Thu Sep 29 12:03:17 2016 -0400

    Convert std::pow usage to shifts.


>---------------------------------------------------------------

d97e6516be74d58f1a1388dde9abae3f57dd9819
 src/mlpack/core/tree/octree/octree_impl.hpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/core/tree/octree/octree_impl.hpp b/src/mlpack/core/tree/octree/octree_impl.hpp
index 436b71e..3da4fc9 100644
--- a/src/mlpack/core/tree/octree/octree_impl.hpp
+++ b/src/mlpack/core/tree/octree/octree_impl.hpp
@@ -711,7 +711,7 @@ void Octree<MetricType, StatisticType, MatType>::SplitNode(
     return;
 
   // This will hold the index of the first point in each child.
-  arma::Col<size_t> childBegins(std::pow(2, dataset->n_rows) + 1);
+  arma::Col<size_t> childBegins(((size_t) 1 << dataset->n_rows) + 1);
   childBegins[0] = begin;
   childBegins[childBegins.n_elem - 1] = begin + count;
 
@@ -741,7 +741,7 @@ void Octree<MetricType, StatisticType, MatType>::SplitNode(
 
     // We can set the first index of the right child.  The first index of the
     // left child is already set.
-    const size_t rightChildIndex = leftChildIndex + std::pow(2, d);
+    const size_t rightChildIndex = leftChildIndex + ((size_t) 1 << d);
     childBegins[rightChildIndex] = firstRight;
 
     // Now we have to recurse, if this was not the last dimension.
@@ -813,7 +813,7 @@ void Octree<MetricType, StatisticType, MatType>::SplitNode(
     return;
 
   // This will hold the index of the first point in each child.
-  arma::Col<size_t> childBegins(std::pow(2, dataset->n_rows) + 1);
+  arma::Col<size_t> childBegins(((size_t) 1 << dataset->n_rows) + 1);
   childBegins[0] = begin;
   childBegins[childBegins.n_elem - 1] = begin + count;
 
@@ -843,7 +843,7 @@ void Octree<MetricType, StatisticType, MatType>::SplitNode(
 
     // We can set the first index of the right child.  The first index of the
     // left child is already set.
-    const size_t rightChildIndex = leftChildIndex + std::pow(2, d);
+    const size_t rightChildIndex = leftChildIndex + ((size_t) 1 << d);
     childBegins[rightChildIndex] = firstRight;
 
     // Now we have to recurse, if this was not the last dimension.




More information about the mlpack-git mailing list