Table of Contents

Delegate DirectILKernelGenerator.SearchSortedKernel

Namespace
NumSharp.Backends.Kernels
Assembly
NumSharp.dll

SearchSorted kernel delegate.

public delegate long DirectILKernelGenerator.SearchSortedKernel(void* arrPtr, long arrLen, long arrStrideBytes, void* keyPtr, long keyLen, void* sorterPtr, long* retPtr)

Parameters

arrPtr void*

Pointer to a's data, already at a.Shape.offset.

arrLen long

Number of elements in a.

arrStrideBytes long

a's stride in bytes (= elemSize when contiguous).

keyPtr void*

Pointer to v's data; v MUST be contiguous (elemSize stride implicit). Not read when keyLen is 0.

keyLen long

Number of elements in v; 0 is legal (only the sorter's middle entry is checked).

sorterPtr void*

Pointer to int64 sorter array (contiguous), or null for no sorter.

retPtr long*

Output int64* (contiguous, keyLen elements). It also holds each key's running base between the bisection's passes, so it must not alias the keys or the haystack.

Returns

long

0 when every key was searched; -1 (NumPy's argbinsearch) when the bisection reached a sorter entry outside [0, arrLen): the search stops there, before that entry addresses arrPtr, and the caller raises NumPy's ValueError: Sorter index out of range. (the bases already written are discarded with the result, as NumPy's are). The middle entry is reached before any key, so -1 can come with no key at all. Always 0 without a sorter.