Skip to main content

function

is_power_of_2

is_power_of_2[type: DType, simd_width: Int](val: SIMD[type, simd_width]) -> SIMD[bool, $1]

Performs elementwise check of whether SIMD vector contains integer powers of two.

An element of the result SIMD vector will be True if the value is an integer power of two, and False otherwise.

Parameters:

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

Args:

  • val (SIMD[type, simd_width]): The SIMD vector to perform is_power_of_2 on.

Returns:

A SIMD vector containing True if the corresponding element in val is a power of two, otherwise False.

is_power_of_2(val: Int) -> Bool

Checks whether an integer is a power of two.

Args:

  • val (Int): The integer to check.

Returns:

True if val is a power of two, otherwise False.