Skip to main content
Log in

Mojo function

iota

iota[type: DType, simd_width: Int](offset: SIMD[type, 1] = SIMD(0)) -> SIMD[type, simd_width]

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

Parameters:

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

Args:

  • offset (SIMD[type, 1]): The value to start the sequence at. Default is zero.

Returns:

An increasing sequence of values, starting from offset.

iota[type: DType](buff: UnsafePointer[SIMD[type, 1]], 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:

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

Args:

  • buff (UnsafePointer[SIMD[type, 1]]): The buffer to fill.
  • len (Int): The length of the buffer to fill.
  • offset (Int): The value to fill at index 0.

iota[type: DType, //](mut v: List[SIMD[type, 1], hint_trivial_type], offset: Int = 0)

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

Parameters:

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

Args:

  • v (List[SIMD[type, 1], hint_trivial_type]): The list to fill with numbers.
  • offset (Int): The starting value to fill at index 0.

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

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

Args:

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