[mlpack-git] master: Fix a bug that meant that centroidsOther was copied only when it shouldn't have been, and was never copied when it should have been (note the iteration++ at the end of the loop). (82a9085)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:01:45 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 82a90857a93332dc1beb8016c54a3711b8feb541
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Oct 14 06:03:48 2014 +0000

    Fix a bug that meant that centroidsOther was copied only when it shouldn't have
    been, and was never copied when it should have been (note the iteration++ at the
    end of the loop).


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

82a90857a93332dc1beb8016c54a3711b8feb541
 src/mlpack/methods/kmeans/kmeans_impl.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mlpack/methods/kmeans/kmeans_impl.hpp b/src/mlpack/methods/kmeans/kmeans_impl.hpp
index 7b8d9a3..317d0c4 100644
--- a/src/mlpack/methods/kmeans/kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/kmeans_impl.hpp
@@ -174,7 +174,7 @@ Cluster(const MatType& data,
   // If we ended on an even iteration, then the centroids are in the
   // centroidsOther matrix, and we need to steal its memory (steal_mem() avoids
   // a copy if possible).
-  if (iteration % 2 == 0)
+  if ((iteration - 1) % 2 == 0)
     centroids.steal_mem(centroidsOther);
 
   if (iteration != maxIterations)



More information about the mlpack-git mailing list