<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * This source code is licensed under the BSD+Patents license found in the</span></div>
<divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment"> * LICENSE file in the root directory of this source tree.</span></div>
<divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> <spanclass="comment">/** Product Quantizer. Implemented only for METRIC_L2 */</span></div>
<divclass="line"><aname="l00026"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a567cd512438f9e3404d9339a232d7695"> 26</a></span> <spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a567cd512438f9e3404d9339a232d7695">d</a>; <spanclass="comment">///< size of the input vectors</span></div>
<divclass="line"><aname="l00027"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a83600e328893ce5f41fe459f5a3acf41"> 27</a></span> <spanclass="comment"></span><spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a83600e328893ce5f41fe459f5a3acf41">M</a>; <spanclass="comment">///< number of subquantizers</span></div>
<divclass="line"><aname="l00028"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#ac920fea11f02e8407d12cc99a09f5ea5"> 28</a></span> <spanclass="comment"></span><spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#ac920fea11f02e8407d12cc99a09f5ea5">nbits</a>; <spanclass="comment">///< number of bits per quantization index</span></div>
<divclass="line"><aname="l00030"></a><spanclass="lineno"> 30</span> <spanclass="comment">// values derived from the above</span></div>
<divclass="line"><aname="l00031"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a467b451ca203544e42c250e4be65b983"> 31</a></span> <spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a467b451ca203544e42c250e4be65b983">dsub</a>; <spanclass="comment">///< dimensionality of each subvector</span></div>
<divclass="line"><aname="l00032"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a13bf69a0dc7b4e45792d10f458e4a92d"> 32</a></span> <spanclass="comment"></span><spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a13bf69a0dc7b4e45792d10f458e4a92d">byte_per_idx</a>; <spanclass="comment">///< nb bytes per code component (1 or 2)</span></div>
<divclass="line"><aname="l00033"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#aa61330eadb84772b71018b093773a5f9"> 33</a></span> <spanclass="comment"></span><spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#aa61330eadb84772b71018b093773a5f9">code_size</a>; <spanclass="comment">///< byte per indexed vector</span></div>
<divclass="line"><aname="l00034"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a0feee45e4151547b7a0444c14bad398f"> 34</a></span> <spanclass="comment"></span><spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a0feee45e4151547b7a0444c14bad398f">ksub</a>; <spanclass="comment">///< number of centroids for each subquantizer</span></div>
<divclass="line"><aname="l00035"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a1e4056fa3938ed8c9fe701e90d94ad95"> 35</a></span> <spanclass="comment"></span><spanclass="keywordtype">bool</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a1e4056fa3938ed8c9fe701e90d94ad95">verbose</a>; <spanclass="comment">///< verbose during training?</span></div>
<divclass="line"><aname="l00041"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a3a41c6286095e731be744548d9535a35a4960d143d2aa49cf92028cf3470c47a0"> 41</a></span> <aclass="code"href="structfaiss_1_1ProductQuantizer.html#a3a41c6286095e731be744548d9535a35a4960d143d2aa49cf92028cf3470c47a0">Train_hot_start</a>, <spanclass="comment">///< the centroids are already initialized</span></div>
<divclass="line"><aname="l00048"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#af265acf5aa1bcda60898002287e6a3d6"> 48</a></span> <aclass="code"href="structfaiss_1_1ClusteringParameters.html">ClusteringParameters</a><aclass="code"href="structfaiss_1_1ProductQuantizer.html#af265acf5aa1bcda60898002287e6a3d6">cp</a>; <spanclass="comment">///< parameters used during clustering</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment"> /// if non-NULL, use this index for assignment (should be of size</span></div>
<divclass="line"><aname="l00051"></a><spanclass="lineno"> 51</span> <spanclass="comment"> /// d / M)</span></div>
<divclass="line"><aname="l00057"></a><spanclass="lineno"> 57</span> <spanclass="comment"> /// return the centroids associated with subvector m</span></div>
<divclass="line"><aname="l00058"></a><spanclass="lineno"><aclass="line"href="structfaiss_1_1ProductQuantizer.html#a4f0f33c011dffe633a1748a48a082c22"> 58</a></span> <spanclass="comment"></span><spanclass="keywordtype">float</span> * <aclass="code"href="structfaiss_1_1ProductQuantizer.html#a4f0f33c011dffe633a1748a48a082c22">get_centroids</a> (<spanclass="keywordtype">size_t</span> m, <spanclass="keywordtype">size_t</span> i) {</div>
<divclass="line"><aname="l00065"></a><spanclass="lineno"> 65</span> <spanclass="comment">// Train the product quantizer on a set of points. A clustering</span></div>
<divclass="line"><aname="l00066"></a><spanclass="lineno"> 66</span> <spanclass="comment">// can be set on input to define non-default clustering parameters</span></div>
<divclass="line"><aname="l00067"></a><spanclass="lineno"> 67</span> <spanclass="keywordtype">void</span> train (<spanclass="keywordtype">int</span> n, <spanclass="keyword">const</span><spanclass="keywordtype">float</span> *x);</div>
<divclass="line"><aname="l00069"></a><spanclass="lineno"> 69</span>  ProductQuantizer(<spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a567cd512438f9e3404d9339a232d7695">d</a>, <spanclass="comment">/* dimensionality of the input vectors */</span></div>
<divclass="line"><aname="l00070"></a><spanclass="lineno"> 70</span> <spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#a83600e328893ce5f41fe459f5a3acf41">M</a>, <spanclass="comment">/* number of subquantizers */</span></div>
<divclass="line"><aname="l00071"></a><spanclass="lineno"> 71</span> <spanclass="keywordtype">size_t</span><aclass="code"href="structfaiss_1_1ProductQuantizer.html#ac920fea11f02e8407d12cc99a09f5ea5">nbits</a>); <spanclass="comment">/* number of bit per subvector index */</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment"> /// compute derived values when d, M and nbits have been set</span></div>
<divclass="line"><aname="l00078"></a><spanclass="lineno"> 78</span> <spanclass="comment"> /// Define the centroids for subquantizer m</span></div>
<divclass="line"><aname="l00081"></a><spanclass="lineno"> 81</span> <spanclass="comment"> /// Quantize one vector with the product quantizer</span></div>
<divclass="line"><aname="l00084"></a><spanclass="lineno"> 84</span> <spanclass="comment"> /// same as compute_code for several vectors</span></div>
<divclass="line"><aname="l00089"></a><spanclass="lineno"> 89</span> <spanclass="comment"> /// decode a vector from a given code (or n vectors if third argument)</span></div>
<divclass="line"><aname="l00093"></a><spanclass="lineno"> 93</span> <spanclass="comment"> /// If we happen to have the distance tables precomputed, this is</span></div>
<divclass="line"><aname="l00094"></a><spanclass="lineno"> 94</span> <spanclass="comment"> /// more efficient to compute the codes.</span></div>
<divclass="line"><aname="l00101"></a><spanclass="lineno"> 101</span> <spanclass="comment"> * The distance table for x = [x_0 x_1 .. x_(M-1)] is a M * ksub</span></div>
<divclass="line"><aname="l00102"></a><spanclass="lineno"> 102</span> <spanclass="comment"> * matrix that contains</span></div>
<divclass="line"><aname="l00107"></a><spanclass="lineno"> 107</span> <spanclass="comment"> * where c_(m, j) is the centroid no j of sub-quantizer m.</span></div>
<divclass="line"><aname="l00119"></a><spanclass="lineno"> 119</span> <spanclass="comment"> /** compute distance table for several vectors</span></div>
<divclass="line"><aname="l00120"></a><spanclass="lineno"> 120</span> <spanclass="comment"> * @param nx nb of input vectors</span></div>
<divclass="line"><aname="l00137"></a><spanclass="lineno"> 137</span> <spanclass="comment"> * @param ncodes nb of nb vectors</span></div>
<divclass="line"><aname="l00138"></a><spanclass="lineno"> 138</span> <spanclass="comment"> * @param res heap array to store results (nh == nx)</span></div>
<divclass="line"><aname="l00148"></a><spanclass="lineno"> 148</span> <spanclass="comment"> /** same as search, but with inner product similarity */</span></div>
<divclass="line"><aname="l00160"></a><spanclass="lineno"> 160</span> <spanclass="comment">// intitialize the SDC table from the centroids</span></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_ad291f113c6d44a634ddc1972f9a3c775"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#ad291f113c6d44a634ddc1972f9a3c775">faiss::ProductQuantizer::set_params</a></div><divclass="ttdeci">void set_params(const float *centroids, int m)</div><divclass="ttdoc">Define the centroids for subquantizer m. </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8cpp_source.html#l00175">ProductQuantizer.cpp:175</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a3a41c6286095e731be744548d9535a35a6b330bc2cfa02a402d002d657f214931"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a3a41c6286095e731be744548d9535a35a6b330bc2cfa02a402d002d657f214931">faiss::ProductQuantizer::Train_hypercube_pca</a></div><divclass="ttdoc">intialize centroids with nbits-D hypercube </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00044">ProductQuantizer.h:44</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_ac920fea11f02e8407d12cc99a09f5ea5"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#ac920fea11f02e8407d12cc99a09f5ea5">faiss::ProductQuantizer::nbits</a></div><divclass="ttdeci">size_t nbits</div><divclass="ttdoc">number of bits per quantization index </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00028">ProductQuantizer.h:28</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a7afbf9d96276f021981e99f064254208"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a7afbf9d96276f021981e99f064254208">faiss::ProductQuantizer::decode</a></div><divclass="ttdeci">void decode(const uint8_t *code, float *x) const </div><divclass="ttdoc">decode a vector from a given code (or n vectors if third argument) </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8cpp_source.html#l00335">ProductQuantizer.cpp:335</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a13bf69a0dc7b4e45792d10f458e4a92d"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a13bf69a0dc7b4e45792d10f458e4a92d">faiss::ProductQuantizer::byte_per_idx</a></div><divclass="ttdeci">size_t byte_per_idx</div><divclass="ttdoc">nb bytes per code component (1 or 2) </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00032">ProductQuantizer.h:32</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a3a41c6286095e731be744548d9535a35ac8040c8792a014a2ea7188583575013e"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a3a41c6286095e731be744548d9535a35ac8040c8792a014a2ea7188583575013e">faiss::ProductQuantizer::Train_hypercube</a></div><divclass="ttdoc">intialize centroids with nbits-D hypercube </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00043">ProductQuantizer.h:43</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_ab3067f333b26811537a8519fb08292ce"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#ab3067f333b26811537a8519fb08292ce">faiss::ProductQuantizer::set_derived_values</a></div><divclass="ttdeci">void set_derived_values()</div><divclass="ttdoc">compute derived values when d, M and nbits have been set </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8cpp_source.html#l00162">ProductQuantizer.cpp:162</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a467b451ca203544e42c250e4be65b983"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a467b451ca203544e42c250e4be65b983">faiss::ProductQuantizer::dsub</a></div><divclass="ttdeci">size_t dsub</div><divclass="ttdoc">dimensionality of each subvector </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00031">ProductQuantizer.h:31</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a0feee45e4151547b7a0444c14bad398f"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a0feee45e4151547b7a0444c14bad398f">faiss::ProductQuantizer::ksub</a></div><divclass="ttdeci">size_t ksub</div><divclass="ttdoc">number of centroids for each subquantizer </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00034">ProductQuantizer.h:34</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a08b130e3a21f2699a4e3bbec121fb838"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a08b130e3a21f2699a4e3bbec121fb838">faiss::ProductQuantizer::compute_code</a></div><divclass="ttdeci">void compute_code(const float *x, uint8_t *code) const </div><divclass="ttdoc">Quantize one vector with the product quantizer. </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8cpp_source.html#l00308">ProductQuantizer.cpp:308</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a3a41c6286095e731be744548d9535a35a4960d143d2aa49cf92028cf3470c47a0"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a3a41c6286095e731be744548d9535a35a4960d143d2aa49cf92028cf3470c47a0">faiss::ProductQuantizer::Train_hot_start</a></div><divclass="ttdoc">the centroids are already initialized </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00041">ProductQuantizer.h:41</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_af265acf5aa1bcda60898002287e6a3d6"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#af265acf5aa1bcda60898002287e6a3d6">faiss::ProductQuantizer::cp</a></div><divclass="ttdeci">ClusteringParameters cp</div><divclass="ttdoc">parameters used during clustering </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00048">ProductQuantizer.h:48</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a83600e328893ce5f41fe459f5a3acf41"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a83600e328893ce5f41fe459f5a3acf41">faiss::ProductQuantizer::M</a></div><divclass="ttdeci">size_t M</div><divclass="ttdoc">number of subquantizers </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00027">ProductQuantizer.h:27</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a4f0f33c011dffe633a1748a48a082c22"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a4f0f33c011dffe633a1748a48a082c22">faiss::ProductQuantizer::get_centroids</a></div><divclass="ttdeci">float * get_centroids(size_t m, size_t i)</div><divclass="ttdoc">return the centroids associated with subvector m </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00058">ProductQuantizer.h:58</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a567cd512438f9e3404d9339a232d7695"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a567cd512438f9e3404d9339a232d7695">faiss::ProductQuantizer::d</a></div><divclass="ttdeci">size_t d</div><divclass="ttdoc">size of the input vectors </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00026">ProductQuantizer.h:26</a></div></div>
<divclass="ttc"id="structfaiss_1_1ProductQuantizer_html_a1e4056fa3938ed8c9fe701e90d94ad95"><divclass="ttname"><ahref="structfaiss_1_1ProductQuantizer.html#a1e4056fa3938ed8c9fe701e90d94ad95">faiss::ProductQuantizer::verbose</a></div><divclass="ttdeci">bool verbose</div><divclass="ttdoc">verbose during training? </div><divclass="ttdef"><b>Definition:</b><ahref="ProductQuantizer_8h_source.html#l00035">ProductQuantizer.h:35</a></div></div>