MCPcopy Index your code
hub / github.com/arrayfire/arrayfire-rust / topk

Function topk

src/statistics/mod.rs:480–498  ·  view source on GitHub ↗

Find top k elements along a given dimension This function returns the top k values along a given dimension of the input array. The indices along with their values are returned. If the input is a multi-dimensional array, the indices will be the index of the value in that dimension. Order of duplicate values are not preserved. This function is optimized for small values of k. Currently, topk elem

(input: &Array<T>, k: u32, dim: i32, order: TopkFn)

Source from the content-addressed store, hash-verified

478/// with the second Array containing the indices of the topk values in the input
479/// data.
480pub fn topk<T>(input: &Array<T>, k: u32, dim: i32, order: TopkFn) -> (Array<T>, Array<u32>)
481where
482 T: HasAfEnum,
483{
484 unsafe {
485 let mut t0: af_array = std::ptr::null_mut();
486 let mut t1: af_array = std::ptr::null_mut();
487 let err_val = af_topk(
488 &mut t0 as *mut af_array,
489 &mut t1 as *mut af_array,
490 input.get(),
491 k as c_int,
492 dim as c_int,
493 order as c_uint,
494 );
495 HANDLE_ERROR(AfError::from(err_val));
496 (t0.into(), t1.into())
497 }
498}
499
500/// Calculate mean and variance in single API call
501///

Callers

nothing calls this directly

Calls 3

HANDLE_ERRORFunction · 0.85
intoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected