From ac018f5f96c32c96158a239fbfeb9dc439c95548 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 24 Jul 2023 11:50:33 -0400 Subject: Cosine Similarity Type --- benchmarks/include/bench_utility.h | 2 +- include/framework/RecordInterface.h | 52 ++++++++++++++++++++++++++++++++++--- tests/testing.h | 2 +- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/benchmarks/include/bench_utility.h b/benchmarks/include/bench_utility.h index a1a2773..b728cbd 100644 --- a/benchmarks/include/bench_utility.h +++ b/benchmarks/include/bench_utility.h @@ -38,7 +38,7 @@ typedef uint64_t weight_type; typedef de::WeightedRecord WRec; typedef de::Record Rec; -typedef de::Point Word2VecRec; +typedef de::CosinePoint Word2VecRec; typedef de::DynamicExtension, de::WSSQuery> ExtendedWSS; typedef de::DynamicExtension, de::TrieSplineRangeQuery> ExtendedTSRQ; diff --git a/include/framework/RecordInterface.h b/include/framework/RecordInterface.h index 8d40590..85a0794 100644 --- a/include/framework/RecordInterface.h +++ b/include/framework/RecordInterface.h @@ -112,10 +112,10 @@ struct WeightedRecord { }; template -struct Point{ +struct CosinePoint{ V data[D]; - inline bool operator==(const Point& other) const { + inline bool operator==(const CosinePoint& other) const { for (size_t i=0; i +struct EuclidPoint{ + V data[D]; + + inline bool operator==(const EuclidPoint& other) const { + for (size_t i=0; i other.data[i]) { + return false; + } + } + + return false; + } + + inline double calc_distance(const EuclidPoint& other) const { double dist = 0; for (size_t i=0; i WRec; typedef de::Record Rec; -typedef de::Point PRec; +typedef de::EuclidPoint PRec; template std::vector strip_wrapping(std::vector> vec) { -- cgit v1.2.3