[mlpack-git] master: The positivity check is unnecessary -- it's a size_t. (a03808a)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Nov 30 11:23:59 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/995e0c0c2f41e45c4d34a54df4bdd743bc920f85...10b9d45b806a3e879b0564d78ccb183ebc7051ba

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

commit a03808a6f23d7caeb141962db4e3ecd6b5a8b550
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Nov 30 08:18:40 2015 -0800

    The positivity check is unnecessary -- it's a size_t.
    
    Also fix type warnings.


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

a03808a6f23d7caeb141962db4e3ecd6b5a8b550
 src/mlpack/core/math/columns_to_blocks.cpp | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/mlpack/core/math/columns_to_blocks.cpp b/src/mlpack/core/math/columns_to_blocks.cpp
index f9ee660..c334710 100644
--- a/src/mlpack/core/math/columns_to_blocks.cpp
+++ b/src/mlpack/core/math/columns_to_blocks.cpp
@@ -21,13 +21,8 @@ ColumnsToBlocks::ColumnsToBlocks(const size_t rows,
 
 bool ColumnsToBlocks::IsPerfectSquare(const size_t value) const
 {
-  if (value < 0)
-  {
-    return false;
-  }
-
-  const int root = std::round(std::sqrt(value));
-  return value == root * root;
+  const size_t root = (size_t) std::round(std::sqrt(value));
+  return (value == root * root);
 }
 
 void ColumnsToBlocks::Transform(const arma::mat& maximalInputs,



More information about the mlpack-git mailing list