Merge pull request #2464 from shrit/pre_increment

Pre increment
This commit is contained in:
Ryan Curtin
2020-06-30 10:48:52 -04:00
committed by GitHub
216 changed files with 1244 additions and 1226 deletions
+15 -15
View File
@@ -39,12 +39,12 @@ BOOST_AUTO_TEST_CASE(AddressTest)
arma::Col<ElemType> point(dataset.n_rows);
// Ensure that this is one-to-one transform.
for (size_t i = 0; i < dataset.n_cols; i++)
for (size_t i = 0; i < dataset.n_cols; ++i)
{
addr::PointToAddress(address, dataset.col(i));
addr::AddressToPoint(point, address);
for (size_t k = 0; k < dataset.n_rows; k++)
for (size_t k = 0; k < dataset.n_rows; ++k)
BOOST_REQUIRE_CLOSE(dataset(k, i), point[k], 1e-13);
}
}
@@ -69,7 +69,7 @@ void CheckSplit(const TreeType& tree)
arma::Col<AddressElemType> address(tree.Bound().Dim());
// Find the highest address of the left node.
for (size_t i = 0; i < tree.Left()->NumDescendants(); i++)
for (size_t i = 0; i < tree.Left()->NumDescendants(); ++i)
{
addr::PointToAddress(address,
tree.Dataset().col(tree.Left()->Descendant(i)));
@@ -79,7 +79,7 @@ void CheckSplit(const TreeType& tree)
}
// Find the lowest address of the right node.
for (size_t i = 0; i < tree.Right()->NumDescendants(); i++)
for (size_t i = 0; i < tree.Right()->NumDescendants(); ++i)
{
addr::PointToAddress(address,
tree.Dataset().col(tree.Right()->Descendant(i)));
@@ -110,7 +110,7 @@ template<typename TreeType>
void CheckBound(const TreeType& tree)
{
typedef typename TreeType::ElemType ElemType;
for (size_t i = 0; i < tree.NumDescendants(); i++)
for (size_t i = 0; i < tree.NumDescendants(); ++i)
{
arma::Col<ElemType> point = tree.Dataset().col(tree.Descendant(i));
@@ -122,10 +122,10 @@ void CheckBound(const TreeType& tree)
// Ensure that there is a hyperrectangle that contains the point.
bool success = false;
for (size_t j = 0; j < tree.Bound().NumBounds(); j++)
for (size_t j = 0; j < tree.Bound().NumBounds(); ++j)
{
success = true;
for (size_t k = 0; k < loBound.n_rows; k++)
for (size_t k = 0; k < loBound.n_rows; ++k)
{
if (point[k] < loBound(k, j) - 1e-14 * std::fabs(loBound(k, j)) ||
point[k] > hiBound(k, j) + 1e-14 * std::fabs(hiBound(k, j)))
@@ -173,12 +173,12 @@ void CheckDistance(TreeType& tree, TreeType* node = NULL)
CheckDistance<TreeType, MetricType>(tree, node);
for (size_t j = 0; j < tree.Dataset().n_cols; j++)
for (size_t j = 0; j < tree.Dataset().n_cols; ++j)
{
const arma::Col<ElemType>& point = tree. Dataset().col(j);
ElemType maxDist = 0;
ElemType minDist = std::numeric_limits<ElemType>::max();
for (size_t i = 0; i < tree.NumDescendants(); i++)
for (size_t i = 0; i < tree.NumDescendants(); ++i)
{
ElemType dist = MetricType::Evaluate(
tree.Dataset().col(tree.Descendant(i)),
@@ -215,8 +215,8 @@ void CheckDistance(TreeType& tree, TreeType* node = NULL)
{
ElemType maxDist = 0;
ElemType minDist = std::numeric_limits<ElemType>::max();
for (size_t i = 0; i < tree.NumDescendants(); i++)
for (size_t j = 0; j < node->NumDescendants(); j++)
for (size_t i = 0; i < tree.NumDescendants(); ++i)
for (size_t j = 0; j < node->NumDescendants(); ++j)
{
ElemType dist = MetricType::Evaluate(
tree.Dataset().col(tree.Descendant(i)),
@@ -292,9 +292,9 @@ BOOST_AUTO_TEST_CASE(UBTreeTest)
BOOST_REQUIRE_EQUAL(root.NumDescendants(), size);
// Check the forward and backward mappings for correctness.
for (size_t i = 0; i < size; i++)
for (size_t i = 0; i < size; ++i)
{
for (size_t j = 0; j < dimensions; j++)
for (size_t j = 0; j < dimensions; ++j)
{
BOOST_REQUIRE_EQUAL(treeset(j, i), dataset(j, newToOld[i]));
BOOST_REQUIRE_EQUAL(treeset(j, oldToNew[i]), dataset(j, i));
@@ -323,7 +323,7 @@ BOOST_AUTO_TEST_CASE(SingleTreeTraverserTest)
knn2.Search(5, neighbors2, distances2);
for (size_t i = 0; i < neighbors1.size(); i++)
for (size_t i = 0; i < neighbors1.size(); ++i)
{
BOOST_REQUIRE_EQUAL(neighbors1[i], neighbors2[i]);
BOOST_REQUIRE_EQUAL(distances1[i], distances2[i]);
@@ -350,7 +350,7 @@ BOOST_AUTO_TEST_CASE(DualTreeTraverserTest)
knn2.Search(5, neighbors2, distances2);
for (size_t i = 0; i < neighbors1.size(); i++)
for (size_t i = 0; i < neighbors1.size(); ++i)
{
BOOST_REQUIRE_EQUAL(neighbors1[i], neighbors2[i]);
BOOST_REQUIRE_EQUAL(distances1[i], distances2[i]);