Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
IndexLSH_c.cpp
1 /**
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD+Patents license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 // Copyright 2004-present Facebook. All Rights Reserved.
10 // -*- c++ -*-
11 
12 #include "IndexLSH_c.h"
13 #include "IndexLSH.h"
14 #include "macros_impl.h"
15 
16 using faiss::Index;
17 using faiss::IndexLSH;
18 
19 DEFINE_DESTRUCTOR(IndexLSH)
20 DEFINE_INDEX_DOWNCAST(IndexLSH)
21 
22 DEFINE_GETTER(IndexLSH, int, nbits)
23 DEFINE_GETTER(IndexLSH, int, bytes_per_vec)
24 DEFINE_GETTER_PERMISSIVE(IndexLSH, int, rotate_data)
25 DEFINE_GETTER_PERMISSIVE(IndexLSH, int, train_thresholds)
26 
27 int faiss_IndexLSH_new(FaissIndexLSH** p_index, idx_t d, int nbits) {
28  try {
29  *p_index = reinterpret_cast<FaissIndexLSH*>(new IndexLSH(d, nbits));
30  } CATCH_AND_HANDLE
31 }
32 
33 int faiss_IndexLSH_new_with_options(FaissIndexLSH** p_index, idx_t d, int nbits, int rotate_data, int train_thresholds) {
34  try {
35  *p_index = reinterpret_cast<FaissIndexLSH*>(
36  new IndexLSH(d, nbits, static_cast<bool>(rotate_data), static_cast<bool>(train_thresholds)));
37  } CATCH_AND_HANDLE
38 }