15 #include "IndexFlat.h"
17 #include "IndexScalarQuantizer.h"
36 std::vector<float> codebook;
38 std::vector<uint8_t> codes;
43 size_t k=256,
size_t nsq=1);
49 size_t compute_distances(
size_t n,
const idx_t *shortlist,
50 const float *query,
float *distances)
const;
53 void estimate_code(
const float *x, storage_idx_t i, uint8_t *code)
const;
56 void reconstruct(storage_idx_t i,
float *x,
float *tmp)
const;
58 void reconstruct_n(storage_idx_t n0, storage_idx_t ni,
float *x)
const;
90 void add(
idx_t n,
const float *x)
override;
97 float *distances,
idx_t *labels)
const override;
101 void reset ()
override;
103 void shrink_level_0_neighbors(
int size);
112 const storage_idx_t *nearest,
const float *nearest_d,
113 float *distances,
idx_t *labels,
int nprobe = 1,
114 int search_type = 1)
const;
118 int k,
const float *D,
const idx_t *I);
122 int npt,
const storage_idx_t *points,
123 const storage_idx_t *nearests);
126 void reorder_links();
128 void link_singletons();
141 get_distance_computer()
const override;
152 get_distance_computer()
const override;
162 get_distance_computer()
const override;
171 get_distance_computer()
const override;
176 float *distances,
idx_t *labels)
const override;
void train(idx_t n, const float *x) override
Trains the storage if needed.
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
entry point for search
void get_neighbor_table(storage_idx_t i, float *out) const
get the M+1 -by-d table for neighbor coordinates for vector i
void train(idx_t n, const float *x) override
Trains the storage if needed.
long idx_t
all indices are this type
void add(idx_t n, const float *x) override
void reconstruct(storage_idx_t i, float *x, float *tmp) const
called by compute_distances
void estimate_code(const float *x, storage_idx_t i, uint8_t *code) const
called by add_codes
void add_codes(size_t n, const float *x)
void reset() override
removes all elements from the database.
void init_level_0_from_entry_points(int npt, const storage_idx_t *points, const storage_idx_t *nearests)
alternative graph building
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
entry point for search
void init_level_0_from_knngraph(int k, const float *D, const idx_t *I)
alternative graph building
void search_level_0(idx_t n, const float *x, idx_t k, const storage_idx_t *nearest, const float *nearest_d, float *distances, idx_t *labels, int nprobe=1, int search_type=1) const
void reconstruct(idx_t key, float *recons) const override
int storage_idx_t
internal storage of vectors (32 bits: this is expensive)