Class: Faiss::IndexBinary

Inherits:
Object
  • Object
show all
Defined in:
lib/faiss/index_binary.rb

Instance Method Summary collapse

Instance Method Details

#add(objects) ⇒ Object



8
9
10
11
# File 'lib/faiss/index_binary.rb', line 8

def add(objects)
  objects = Numo::UInt8.cast(objects) unless objects.is_a?(Numo::UInt8)
  _add(objects.shape[0], objects)
end

#search(objects, k) ⇒ Object



13
14
15
16
17
18
# File 'lib/faiss/index_binary.rb', line 13

def search(objects, k)
  objects = Numo::UInt8.cast(objects) unless objects.is_a?(Numo::UInt8)
  n = objects.shape[0]
  distances, labels = _search(n, objects, k)
  [Numo::UInt32.from_binary(distances).reshape(n, k), Numo::Int64.from_binary(labels).reshape(n, k)]
end

#train(objects) ⇒ Object



3
4
5
6
# File 'lib/faiss/index_binary.rb', line 3

def train(objects)
  objects = Numo::UInt8.cast(objects) unless objects.is_a?(Numo::UInt8)
  _train(objects.shape[0], objects)
end