9 #ifndef FAISS_INDEX_SCALAR_QUANTIZER_H
10 #define FAISS_INDEX_SCALAR_QUANTIZER_H
30 struct ScalarQuantizer {
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;
135 std::vector<std::vector<uint8_t> >
codes;
152 idx_t* labels)
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
std::vector< float > trained
trained values (including the range)
void train_residual(idx_t n, const float *x) override
void add(idx_t n, const float *x) override
void reset() override
removes all elements from the database.
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
void merge_from_residuals(IndexIVF &other) override
alternate optimization of reconstruction error
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
same, shared range for all dimensions
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
[min - rs*(max-min), max + rs*(max-min)]
size_t nlist
number of possible key values
void reconstruct_n(idx_t i0, idx_t ni, float *recons) const override
std::vector< std::vector< uint8_t > > codes
inverted list codes.
void reconstruct(idx_t key, float *recons) const override
[mean - std * rs, mean + std * rs]
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.