10 #include "IndexBinary.h"
11 #include "FaissAssert.h"
17 IndexBinary::~IndexBinary() {}
25 FAISS_THROW_MSG(
"range search not implemented");
29 int *distances =
new int[n * k];
31 search(n, x, k, distances, labels);
35 FAISS_THROW_MSG(
"add_with_ids not implemented for this type of index");
39 FAISS_THROW_MSG(
"remove_ids not implemented for this type of index");
44 FAISS_THROW_MSG(
"reconstruct not implemented for this type of index");
48 for (
idx_t i = 0; i < ni; i++) {
54 int32_t *distances,
idx_t *labels,
55 uint8_t *recons)
const {
56 search(n, x, k, distances, labels);
57 for (
idx_t i = 0; i < n; ++i) {
58 for (
idx_t j = 0; j < k; ++j) {
60 idx_t key = labels[ij];
61 uint8_t *reconstructed = recons + ij *
d;
64 memset(reconstructed, -1,
sizeof(*reconstructed) * d);
73 printf(
"Index: %s -> %ld elements\n",
typeid (*this).name(),
ntotal);
virtual void search(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels) const =0
virtual long remove_ids(const IDSelector &sel)
virtual void train(idx_t n, const uint8_t *x)
Index::idx_t idx_t
all indices are this type
virtual void reconstruct(idx_t key, uint8_t *recons) const
void assign(idx_t n, const uint8_t *x, idx_t *labels, idx_t k=1)
virtual void range_search(idx_t n, const uint8_t *x, int radius, RangeSearchResult *result) const
virtual void add_with_ids(idx_t n, const uint8_t *x, const long *xids)
virtual void search_and_reconstruct(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels, uint8_t *recons) const
virtual void reconstruct_n(idx_t i0, idx_t ni, uint8_t *recons) const
idx_t ntotal
total nb of indexed vectors