48 std::vector<ScalarType>
_x;
81 for(
int d = 0; d < t1.
dimensionality(); d++) dd += (t1.
x(d) - t2.
x(d)) * (t1.
x(d) - t2.
x(d));
86 template<
typename T, ScalarType (*distance)( const T&, const T& )>
100 void create(
const std::vector<T>& items) {
107 void search(
const T& target,
int k, std::vector<T>* results, std::vector<ScalarType>* distances)
111 std::priority_queue<HeapItem> heap;
120 results->clear(); distances->clear();
121 while(!heap.empty()) {
122 results->push_back(
_items[heap.top().index]);
123 distances->push_back(heap.top().dist);
128 std::reverse(results->begin(), results->end());
129 std::reverse(distances->begin(), distances->end());
186 if (upper == lower) {
194 if (upper - lower > 1) {
201 int median = (upper + lower) / 2;
202 std::nth_element(
_items.begin() + lower + 1,
221 void search(
Node* node,
const T& target,
int k, std::priority_queue<HeapItem>& heap)
223 if(node == NULL)
return;
230 if(heap.size() ==
static_cast<size_t>(k)) heap.pop();
232 if(heap.size() ==
static_cast<size_t>(k))
_tau = heap.top().dist;
236 if(node->
left == NULL && node->
right == NULL) {
241 if(dist < node->threshold) {
252 if (dist - _tau <= node->threshold) {
ScalarType distance(Callback &cb, const CoverTreePoint< RandomAccessIterator > &l, const CoverTreePoint< RandomAccessIterator > &r, ScalarType upper_bound)
bool operator()(const T &a, const T &b)
bool operator<(const HeapItem &o) const
DataPoint(const DataPoint &other)
HeapItem(int indexv, ScalarType distv)
void search(const T &target, int k, std::vector< T > *results, std::vector< ScalarType > *distances)
ScalarType uniform_random()
double ScalarType
default scalar value (can be overrided with TAPKEE_CUSTOM_INTERNAL_NUMTYPE define) ...
DistanceComparator(const T &itemv)
std::vector< ScalarType > _x
ScalarType x(int d) const
struct tsne::VpTree::Node * _root
void search(Node *node, const T &target, int k, std::priority_queue< HeapItem > &heap)
Node & operator=(const Node &)
int dimensionality() const
ScalarType euclidean_distance(const DataPoint &t1, const DataPoint &t2)
void create(const std::vector< T > &items)
VpTree & operator=(const VpTree &)
DataPoint(int Dv, int indv, ScalarType *xv)
DataPoint & operator=(const DataPoint &other)
Node * buildFromPoints(int lower, int upper)