From 99d957ea185c3641e407b73a757bc9e2b5673686 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 17 Jul 2023 13:50:42 -0400 Subject: VPTree: changed Point format to a D-dimensional point. --- include/framework/RecordInterface.h | 30 ++++++++++++++++++++++++------ tests/vptree_tests.cpp | 12 ++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/framework/RecordInterface.h b/include/framework/RecordInterface.h index ab4c6f9..a3f6814 100644 --- a/include/framework/RecordInterface.h +++ b/include/framework/RecordInterface.h @@ -100,22 +100,40 @@ struct WeightedRecord { } }; -template +template struct Point{ - V x; - V y; + V data[D]; inline bool operator==(const Point& other) const { - return x == other.x && y == other.y; + for (size_t i=0; i other.data[i]) { + return false; + } + } + + return false; } inline double calc_distance(const Point& other) const { - return sqrt(pow(x - other.x, 2) + pow(y - other.y, 2)); + double dist = 0; + for (size_t i=0; iget_data() + i); - r.x = rec->rec.x; - r.y = rec->rec.y; + r.data[0] = rec->rec.data[0]; + r.data[1] = rec->rec.data[1]; auto result = wss.point_lookup(r); ck_assert_ptr_nonnull(result); - ck_assert_int_eq(result->rec.x, r.x); - ck_assert_int_eq(result->rec.y, r.y); + ck_assert_int_eq(result->rec.data[0], r.data[0]); + ck_assert_int_eq(result->rec.data[1], r.data[1]); } delete buffer; @@ -97,8 +97,8 @@ START_TEST(t_point_lookup_miss) for (size_t i=n + 100; i<2*n; i++) { PRec r; - r.x = i; - r.y = i; + r.data[0] = i; + r.data[1] = i; auto result = wss.point_lookup(r); ck_assert_ptr_null(result); -- cgit v1.2.3