Skip to main content

lc_knearest_csr

Function lc_knearest_csr 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lc_knearest_csr( xyz: *const f64, n: usize, simbox: *const lc_cell, k: usize, mask: *const c_int, cell_hint: f64, mutual: c_int, out_offsets: *mut c_int, alloc: Option<extern "C" fn(*mut c_void, usize) -> *mut c_int>, ctx: *mut c_void, ) -> c_int
Expand description

The k-nearest graph of n points as CSR.

Inputs are those of lc_knearest. Row i of the nominations is its k nearest, nearest first. With mutual nonzero, row i holds every j that row i lists and that lists i: the lower indices ascending, then the higher ones nearest first. Otherwise each edge comes from one nomination slot s = i * k + t: the lower index’s when both rows list each other, the only one that names it when one does. A row holds its edges in slot order: edges from lower rows ascending, then its own nearest first, then edges from higher rows ascending.

out_offsets is caller-owned, n + 1 ints. alloc(ctx, total) is called once, from any thread of the search, and returns total writable ints for the columns; null fails the call. The search, the degrees, and the fill run in one parallel region.

§Safety

Same pointer contract as lc_knearest. out_offsets is writable for n + 1 ints. alloc returns null or total writable ints and does not unwind.