numojo.core.indexing.offset¶
Offset computation (numojo.core.indexing.offset)
Indexing offset calculation functions. These functions compute the flat index (offset) in memory for a given set of multi-dimensional indices and strides. They are used to translate multi-dimensional indexing into flat memory access, which is essential for efficient array operations in NuMojo.
Structs¶
IndexMethods¶
Memory convention: memory_only
Implements: AnyType, ImplicitlyDestructible
Aliases¶
__del__is_trivial¶
Value: True
Methods¶
get_1d_index¶
Overload 1¶
static
Get the flat index from a list of indices and NDArrayStrides.
Args:
indices(List): The list of indices.strides(NDArrayStrides): The strides of the array.
Returns:
Int
Overload 2¶
static
Get the flat index from an Item and NDArrayStrides.
Args:
indices(Item): The Item containing indices.strides(NDArrayStrides): The strides of the array.
Returns:
Int
Overload 3¶
static
Get the flat index from a variadic list of indices and NDArrayStrides.
Args:
indices(VariadicList): The variadic list of indices.strides(NDArrayStrides): The strides of the array.
Returns:
Int
Overload 4¶
static
Get the flat index from a list of indices and a list of strides.
Args:
indices(List): The list of indices.strides(List): The list of strides.
Returns:
Int
Overload 5¶
static
Get the flat index from variadic lists of indices and strides.
Args:
indices(VariadicList): The variadic list of indices.strides(VariadicList): The variadic list of strides.
Returns:
Int
Overload 6¶
static
Get the flat index for a 2D matrix from tuples of indices and strides.
Args:
indices(Tuple): The tuple of indices (row, col).strides(Tuple): The tuple of strides.
Returns:
Int
transfer_offset¶
static
Transfers the offset by flipping the strides information. Used to transfer between C-contiguous and F-continuous memory layouts.
Args:
offset(Int): The offset in memory of an element.strides(NDArrayStrides): The strides of the array.
Returns:
Int
Raises