11 #ifndef FAISS_INDEX_SCALAR_QUANTIZER_H
12 #define FAISS_INDEX_SCALAR_QUANTIZER_H
71 void train (
size_t n,
const float *x);
80 void decode (
const uint8_t *code,
float *x,
size_t n)
const;
88 const uint8_t *code)
const = 0;
92 const uint8_t *code2)
const = 0;
125 void add(
idx_t n,
const float* x)
override;
132 idx_t* labels)
const override;
134 void reset()
override;
161 const idx_t *list_nos,
162 uint8_t * codes)
const override;
171 float* recons)
const override;
void encode_vectors(idx_t n, const float *x, const idx_t *list_nos, uint8_t *codes) 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 reconstruct_from_offset(long list_no, long offset, float *recons) const override
void add(idx_t n, const float *x) override
virtual float compute_distance(const float *x, const uint8_t *code) const =0
vector-to-code distance computation
void reset() override
removes all elements from the database.
void add_with_ids(idx_t n, const float *x, const long *xids) override
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
[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)
InvertedListScanner * get_InvertedListScanner(bool store_pairs) const override
get a scanner for this index (store_pairs means ignore labels)
void compute_codes(const float *x, uint8_t *codes, size_t n) const
same as compute_code for several vectors
virtual float compute_code_distance(const uint8_t *code1, const uint8_t *code2) const =0
code-to-code distance computation
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)
Index * quantizer
quantizer that maps vectors to inverted lists
void train(idx_t n, const float *x) override
size_t d
dimension of input vectors
size_t nlist
number of possible key values
MetricType
Some algorithms support both an inner product version and a L2 search version.