Delegate UnravelIndexMagicKernel
The reciprocal twin of UnravelIndexKernel: the same contract, but each peeled dimension is divided by a precomputed invariant reciprocal (Granlund & Montgomery, "Division by Invariant Integers using Multiplication", Fig. 4.1) instead of the hardware divide. Exact for every non-negative index and every POSITIVE dimension; a negative dimension (C's truncating division of a negative running quotient) must take UnravelIndexKernel.
public delegate long UnravelIndexMagicKernel(long* indices, long count, long* divisors, long unravelSize, long* @out, long ndim, long idxStart, long idxStep)
Parameters
indiceslong*The int64 flat indices, read linearly in NumPy's iteration order.
countlongThe number of indices.
divisorslong*Four int64 per dimension, filled by FillUnravelDivisor(long, Span<long>): the dimension, the magic multiplier, and the two shift counts.
unravelSizelongThe product of the dimensions; an index outside
[0, unravelSize)stops the kernel.outlong*The
count * ndiminterleaved output (row i = element i's coordinates).ndimlongThe number of dimensions, at least 1.
idxStartlongndim - 1for C order, 0 for F order.idxSteplong-1for C order,+1for F order.
Returns
- long
counton success, else the row index of the first out-of-range element.