Skip to main content

Mojo function

iota

iota[dtype: DType, width: Int](offset: Scalar[dtype] = 0) -> SIMD[dtype, width]

Creates a SIMD vector containing an increasing sequence, starting from offset.

Parameters:

  • dtype (DType): The dtype of the input and output SIMD vector.
  • width (Int): The width of the input and output SIMD vector.

Args:

  • offset (Scalar): The value to start the sequence at. Default is zero.

Returns:

SIMD: An increasing sequence of values, starting from offset.

iota[dtype: DType, //](buff: UnsafePointer[Scalar[dtype], origin, address_space=address_space], len: Int, offset: Int = 0)

Fill the buffer with numbers ranging from offset to offset + len - 1, spaced by 1.

The function doesn't return anything, the buffer is updated inplace.

Parameters:

  • dtype (DType): DType of the underlying data.

Args:

  • buff (UnsafePointer): The buffer to fill.
  • len (Int): The length of the buffer to fill.
  • offset (Int): The value to fill at index 0.

iota[dtype: DType, //](mut v: List[Scalar[dtype]], offset: Int = 0)

Fill a list with consecutive numbers starting from the specified offset.

Parameters:

  • dtype (DType): DType of the underlying data.

Args:

  • v (List): The list to fill with numbers.
  • offset (Int): The starting value to fill at index 0.

iota(mut v: List[Int], offset: Int = 0)

Fill a list with consecutive numbers starting from the specified offset.

Args:

  • v (List): The list to fill with numbers.
  • offset (Int): The starting value to fill at index 0.

Was this page helpful?