Epsilon Neighborhood

View as Markdown

Source header: cuvs/neighbors/epsilon_neighborhood.hpp

Epsilon Neighborhood L2 Operations

neighbors::epsilon_neighborhood::compute

Computes epsilon neighborhood for the given distance metric and ball size.

1template <typename value_t, typename idx_t, typename matrix_idx_t>
2void compute(raft::resources const& handle,
3raft::device_matrix_view<const value_t, matrix_idx_t, raft::row_major> x,
4raft::device_matrix_view<const value_t, matrix_idx_t, raft::row_major> y,
5raft::device_matrix_view<bool, matrix_idx_t, raft::row_major> adj,
6raft::device_vector_view<idx_t, matrix_idx_t> vd,
7value_t eps,
8cuvs::distance::DistanceType metric = cuvs::distance::DistanceType::L2Unexpanded);

The epsilon neighbors is represented by a dense boolean adjacency matrix of size m * n and an array of degrees for each vertex, which can be used as a compressed sparse row (CSR) indptr array.

Currently, only L2Unexpanded (L2-squared) distance metric is supported. Other metrics will throw an exception.

Template Parameters

NameTypeDescription
value_tIO and math type
idx_tIndex type
matrix_idx_tmatrix indexing type

Parameters

NameDirectionTypeDescription
handleinraft::resources const&raft handle to manage library resources
xinraft::device_matrix_view<const value_t, matrix_idx_t, raft::row_major>first matrix [row-major] [on device] [dim = m x k]
yinraft::device_matrix_view<const value_t, matrix_idx_t, raft::row_major>second matrix [row-major] [on device] [dim = n x k]
adjoutraft::device_matrix_view<bool, matrix_idx_t, raft::row_major>adjacency matrix [row-major] [on device] [dim = m x n]
vdoutraft::device_vector_view<idx_t, matrix_idx_t>vertex degree array [on device] [len = m + 1] vd + m stores the total number of edges in the adjacency matrix. Pass a nullptr if you don’t need this info.
epsinvalue_tdefines epsilon neighborhood radius (should be passed as squared when using L2Unexpanded metric)
metricincuvs::distance::DistanceTypedistance metric to use. Currently only L2Unexpanded is supported. Default: cuvs::distance::DistanceType::L2Unexpanded.

Returns

void