9 #ifndef FAISS_INDEX_SCALAR_QUANTIZER_H
10 #define FAISS_INDEX_SCALAR_QUANTIZER_H
68 void train (
size_t n,
const float *x);
77 void decode (
const uint8_t *code,
float *x,
size_t n)
const;
105 void add(
idx_t n,
const float* x)
override;
112 idx_t* labels)
const override;
114 void reset()
override;
144 const float *centroid_dis,
145 float *distances,
idx_t *labels,
146 bool store_pairs)
const override;
size_t code_size
bytes per vector
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
void train_residual(idx_t n, const float *x) override
alternate optimization of reconstruction error
same, shared range for all dimensions
void add(idx_t n, const float *x) override
void assign(idx_t n, const float *x, idx_t *labels, idx_t k=1)
void reset() override
removes all elements from the database.
void add_with_ids(idx_t n, const float *x, const long *xids) override
Index * quantizer
quantizer that maps vectors to inverted lists
std::vector< uint8_t > codes
Codes. Size ntotal * pq.code_size.
ScalarQuantizer sq
Used to encode the vectors.
long idx_t
all indices are this type
void search_preassigned(idx_t n, const float *x, idx_t k, const idx_t *assign, const float *centroid_dis, float *distances, idx_t *labels, bool store_pairs) const override
[mean - std * rs, mean + std * rs]
void decode(const uint8_t *code, float *x, size_t n) const
decode a vector from a given code (or n vectors if third argument)
void compute_codes(const float *x, uint8_t *codes, size_t n) const
same as compute_code for several vectors
size_t nlist
number of possible key values
void reconstruct_n(idx_t i0, idx_t ni, float *recons) const override
void reconstruct(idx_t key, float *recons) const override
[min - rs*(max-min), max + rs*(max-min)]
std::vector< float > trained
trained values (including the range)
void train(idx_t n, const float *x) override
size_t d
dimension of input vectors
MetricType
Some algorithms support both an inner product vetsion and a L2 search version.