MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / one_bit_code

Function one_bit_code

include/rabitqlib/quantization/rabitq_impl.hpp:39–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37template <typename T>
38inline RowMajorArray<T> one_bit_code(
39 const T* data, const T* centroid, size_t dim, int* binary_code
40) {
41 // map pointer to array
42 ConstRowMajorArrayMap<T> data_arr(data, 1, dim);
43 ConstRowMajorArrayMap<T> cent_arr(centroid, 1, dim);
44
45 // residual vector
46 RowMajorArray<T> residual_arr = data_arr - cent_arr;
47
48 // unsigned representation
49 RowMajorArrayMap<int> x_u(binary_code, 1, static_cast<long>(dim));
50 x_u = (residual_arr > 0).template cast<int>();
51
52 return residual_arr;
53}
54
55/**
56 * @brief The one_bit_code_with_factor function maps a data vector to a binary code and
57 * computes factors for distance estimation.

Callers 3

one_bit_code_with_factorFunction · 0.85
rabitq_scalar_implFunction · 0.85
rabitq_full_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected