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

Function ex_bits_code

include/rabitqlib/quantization/rabitq_impl.hpp:407–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405template <typename T, typename TP>
406inline T ex_bits_code(
407 const T* residual, size_t dim, size_t ex_bits, TP* ex_code, double t_const = -1
408) {
409 ConstRowMajorArrayMap<T> res_arr(residual, 1, dim);
410
411 // get normalized abs residual for plus code
412 RowMajorArray<T> abs_res = res_arr.rowwise().normalized().abs();
413
414 // quantize data
415 T ipnorm_inv = 1;
416 if (t_const > 0) {
417 ipnorm_inv = faster_quantize_ex(abs_res.data(), ex_code, dim, ex_bits, t_const);
418 } else {
419 ipnorm_inv = quantize_ex(abs_res.data(), ex_code, dim, ex_bits);
420 }
421
422 // revert codes for negative dims
423 int32_t mask = (1 << ex_bits) - 1;
424 for (size_t j = 0; j < dim; ++j) {
425 if (res_arr.data()[j] < 0) {
426 TP tmp = ex_code[j];
427 ex_code[j] = (~tmp) & mask;
428 }
429 }
430
431 return ipnorm_inv;
432}
433
434template <typename T, typename TP>
435inline void ex_bits_code_with_factor(
436 const T* data,

Callers

nothing calls this directly

Calls 5

faster_quantize_exFunction · 0.85
quantize_exFunction · 0.85
rowwiseMethod · 0.80
normalizedMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected