IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

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[dtype]): The value to start the sequence at. Default is zero.

Returns:

SIMD[dtype, width]: An increasing sequence of values, starting from offset.

iota[dtype: DType, //](buff: UnsafePointer[Scalar[dtype], address_space=buff.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:

iota[dtype: DType, //](span: Span[Scalar[dtype]], offset: Int = 0)

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

Parameters:

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

Args:

  • span (Span[Scalar[dtype]]): The Span to fill with numbers.
  • offset (Int): The starting value to fill at index 0.

iota(span: Span[Int], offset: Int = 0)

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

Args:

  • span (Span[Int]): The Span to fill with numbers.
  • offset (Int): The starting value to fill at index 0.