| 37 | template <typename T> |
| 38 | inline 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. |
no outgoing calls
no test coverage detected