Skip to content

closest_vec

closest_vec(x, ic)

Categories: Indexing

Description

finds the closest neighbors for each row of X ignoring the self. Treated as a X=[v1,v2,v3,...], computes sum{(vi-vj)**2} for all i!=j and places minimum in ic.

Parameters

Name Description
ic Output array of shape (nv,). For each row i, ic[i] = index j of the nearest neighbor (j != i).
x 2D array of feature vectors, shape (nv, dim). Each row is a vector.

Constraints

  • x.format == 'd'
  • x.ndim == 2
  • x.shape[1] >= 1
  • ( ic.format == 'i' or ic.format == 'l' )
  • ic.n == x.shape[0]

Overloads

C function Condition
closest_vec always

Built from commit 7ba8255fa8d680e1a1df79e67aee3873247ce69c (v0.4.5)