diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp index 92b15927fb..f75070ea4a 100644 --- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp @@ -586,7 +586,8 @@ void BinarySpaceTree:: SplitType, MatType>& splitter) { // We need to expand the bounds of this node properly. - bound |= dataset->cols(begin, begin + count - 1); + if (count > 0) + bound |= dataset->cols(begin, begin + count - 1); // Calculate the furthest descendant distance. furthestDescendantDistance = 0.5 * bound.Diameter(); @@ -643,7 +644,8 @@ SplitNode(std::vector& oldFromNew, { // This should be a single function for Bound. // We need to expand the bounds of this node properly. - bound |= dataset->cols(begin, begin + count - 1); + if (count > 0) + bound |= dataset->cols(begin, begin + count - 1); // Calculate the furthest descendant distance. furthestDescendantDistance = 0.5 * bound.Diameter();