11 #include "IndexBinary.h"
12 #include "FaissAssert.h"
18 IndexBinary::~IndexBinary() {}
26 FAISS_THROW_MSG(
"range search not implemented");
30 int *distances =
new int[n * k];
32 search(n, x, k, distances, labels);
36 FAISS_THROW_MSG(
"add_with_ids not implemented for this type of index");
40 FAISS_THROW_MSG(
"remove_ids not implemented for this type of index");
45 FAISS_THROW_MSG(
"reconstruct not implemented for this type of index");
49 for (
idx_t i = 0; i < ni; i++) {
55 int32_t *distances,
idx_t *labels,
56 uint8_t *recons)
const {
57 search(n, x, k, distances, labels);
58 for (
idx_t i = 0; i < n; ++i) {
59 for (
idx_t j = 0; j < k; ++j) {
61 idx_t key = labels[ij];
62 uint8_t *reconstructed = recons + ij *
d;
65 memset(reconstructed, -1,
sizeof(*reconstructed) * d);
74 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)
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
long idx_t
all indices are this type