Table of Contents

Delegate UnravelIndexMagicKernel

Namespace
NumSharp.Backends.Kernels
Assembly
NumSharp.dll

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

indices long*

The int64 flat indices, read linearly in NumPy's iteration order.

count long

The number of indices.

divisors long*

Four int64 per dimension, filled by FillUnravelDivisor(long, Span<long>): the dimension, the magic multiplier, and the two shift counts.

unravelSize long

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

out long*

The count * ndim interleaved output (row i = element i's coordinates).

ndim long

The number of dimensions, at least 1.

idxStart long

ndim - 1 for C order, 0 for F order.

idxStep long

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

Returns

long

count on success, else the row index of the first out-of-range element.