-
Notifications
You must be signed in to change notification settings - Fork 10
/
annoy.h
41 lines (31 loc) · 1.12 KB
/
annoy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef ANNOY_H
#define ANNOY_H
#include "utils.h"
// turn off AVX always, to avoid small inconsistencies in distance calculations.
#define NO_MANUAL_VECTORIZATION 1
#include "annoy/RcppAnnoy.h"
#if RCPPANNOY_VERSION < RcppAnnoyVersion(0,1,17,3)
typedef AnnoyIndexSingleThreadedBuildPolicy RcppAnnoyIndexThreadPolicy;
#endif
template<class Distance>
class Annoy {
public:
Annoy(int, const std::string&, double);
void find_nearest_neighbors(CellIndex_t, NumNeighbors_t, const bool, const bool);
void find_nearest_neighbors(const double*, NumNeighbors_t, const bool, const bool);
MatDim_t get_nobs() const;
MatDim_t get_ndims() const;
typedef int32_t Index_t;
typedef float Data_t;
typedef AnnoyIndex<Index_t, Data_t, Distance, Kiss64Random, RcppAnnoyIndexThreadPolicy> _index;
const std::vector<Index_t>& get_neighbors () const;
const std::vector<Data_t>& get_distances () const;
private:
MatDim_t NDims;
_index obj;
std::vector<Index_t> kept_idx;
std::vector<Data_t> kept_dist, holding;
const double search_mult;
NumNeighbors_t get_search_k(NumNeighbors_t);
};
#endif