Open flying-sheep opened 7 years ago
you hardcode euclidean distance and Eigen::VectorXd points. i would prefer to have the options of
Eigen::VectorXd
i.e. i’d like to have
template<Point> class CoverTree { ... }
with Point needing to specify distance and operator==, e.g.:
Point
distance
operator==
template<class Distance, class Vector> class IndexedPoint { private: Vector _vec; size_t _idx; public: IndexedPoint(Vector v, size_t i) : _vec(v), _idx(i) {} const Vector& vec() const { return this->_vec; } size_t idx() const { return this->_idx; } bool operator==(const IndexedPoint<Distance>& p) { return is_true(all(this->_vec == p.vec())); }; double distance(const IndexedPoint<Distance>& p) const { return Distance::distance(*this, p); }; }; class CosineDistance { public: static double distance(const IndexedPoint<CosineDistance>& p1, const IndexedPoint<CosineDistance>& p2) { return 1 - cor(p1.vec(), p2.vec()); } }; class EuclideanDistance { ... }
then i can do:
CoverTree<IndexedPoint<EuclideanDistance>> ct;
you hardcode euclidean distance and
Eigen::VectorXd
points. i would prefer to have the options ofi.e. i’d like to have
with
Point
needing to specifydistance
andoperator==
, e.g.:then i can do: