Delegate UnravelIndexKernel
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
indiceslong*The int64 flat indices, read linearly (the caller lays them out in NumPy's iteration order, so row
ibelongs to thei-th element NumPy visits).countlongThe number of indices.
dimslong*The unravel shape,
ndimentries.unravelSizelongThe product of
dims; an index outside[0, unravelSize)stops the kernel.outlong*The
count * ndiminterleaved output; rows past a failing element are not written.ndimlongThe number of dimensions, at least 1 (the caller answers
shape=()itself).idxStartlongThe first dimension a divmod peels:
ndim - 1for C order, 0 for F order.idxSteplong-1for C order,+1for F order.
Returns
- long
counton success. On failure, the row index of the first element withval < 0orval >= unravelSize; the caller readsindices[returned]to produce the error message.