Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/data/users/hoss/faiss/IndexIVFSpectralHash.h
1 /**
2  * Copyright (c) Facebook, Inc. and its affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 // -*- c++ -*-
9 
10 #ifndef FAISS_INDEX_IVFSH_H
11 #define FAISS_INDEX_IVFSH_H
12 
13 
14 #include <vector>
15 
16 #include "IndexIVF.h"
17 
18 
19 namespace faiss {
20 
21 struct VectorTransform;
22 
23 /** Inverted list that stores binary codes of size nbit. Before the
24  * binary conversion, the dimension of the vectors is transformed from
25  * dim d into dim nbit by vt (a random rotation by default).
26  *
27  * Each coordinate is subtracted from a value determined by
28  * threshold_type, and split into intervals of size period. Half of
29  * the interval is a 0 bit, the other half a 1.
30  */
32 
33  VectorTransform *vt; // transformation from d to nbit dim
34  bool own_fields;
35 
36  int nbit;
37  float period;
38 
39  enum ThresholdType {
40  Thresh_global,
41  Thresh_centroid,
42  Thresh_centroid_half,
43  Thresh_median
44  };
45  ThresholdType threshold_type;
46 
47  // size nlist * nbit or 0 if Thresh_global
48  std::vector<float> trained;
49 
50  IndexIVFSpectralHash (Index * quantizer, size_t d, size_t nlist,
51  int nbit, float period);
52 
54 
55  void train_residual(idx_t n, const float* x) override;
56 
57  void encode_vectors(idx_t n, const float* x,
58  const idx_t *list_nos,
59  uint8_t * codes) const override;
60 
62  const override;
63 
64  ~IndexIVFSpectralHash () override;
65 
66 };
67 
68 
69 
70 
71 }; // namespace faiss
72 
73 
74 #endif
InvertedListScanner * get_InvertedListScanner(bool store_pairs) const override
get a scanner for this index (store_pairs means ignore labels)
int d
vector dimension
Definition: Index.h:66
long idx_t
all indices are this type
Definition: Index.h:62
void train_residual(idx_t n, const float *x) override
void encode_vectors(idx_t n, const float *x, const idx_t *list_nos, uint8_t *codes) const override
Index * quantizer
quantizer that maps vectors to inverted lists
Definition: IndexIVF.h:32
size_t nlist
number of possible key values
Definition: IndexIVF.h:33