Table of Contents

Delegate UnravelIndexKernel

Namespace
NumSharp.Backends.Kernels
Assembly
NumSharp.dll

IL-emitted flat→multi-coord expander for np.unravel_index. Caller pre-casts indices to int64 and computes unravelSize = product of dims; the kernel reads indices linearly, validates each value against [0, unravelSize), and writes element i's coordinates into the row out[indim .. indim+ndim-1] of the interleaved buffer out, using the C-order or F-order extraction direction selected by idxStart / idxStep.

public delegate long UnravelIndexKernel(long* indices, long count, long* dims, long unravelSize, long* @out, long ndim, long idxStart, long idxStep)

Parameters

indices long*

The int64 flat indices, read linearly (the caller lays them out in NumPy's iteration order, so row i belongs to the i-th element NumPy visits).

count long

The number of indices.

dims long*

The unravel shape, ndim entries.

unravelSize long

The product of dims; an index outside [0, unravelSize) stops the kernel.

out long*

The count * ndim interleaved output; rows past a failing element are not written.

ndim long

The number of dimensions, at least 1 (the caller answers shape=() itself).

idxStart long

The first dimension a divmod peels: ndim - 1 for C order, 0 for F order.

idxStep long

-1 for C order, +1 for F order.

Returns

long

count on success. On failure, the row index of the first element with val < 0 or val >= unravelSize; the caller reads indices[returned] to produce the error message.