Module

Defines math utilities.

## abs

abs(x: Int) -> Int

Absolute value of an integer.

Args:

• x (Int): Value to take the absolute value of.

Returns:

The absolute value of x.

abs[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise absolute value on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform absolute value on.

Returns:

The elementwise absolute value of x.

## acos

acos[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the acos of the inputs.

Constraints:

The input must be a floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The acos of the input.

## acosh

acosh[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the acosh of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The acosh of the input.

add[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise addition of two SIMD vectors.

Parameters:

• simd_width (Int): Width of the input SIMD vectors.
• type (DType): DType of the input SIMD vectors.

Args:

• x (SIMD[type, simd_width]): First SIMD vector to add.
• y (SIMD[type, simd_width]): Second SIMD vector to add.

Returns:

Elementwise addition of x and y.

## align_down

align_down(value: Int, alignment: Int) -> Int

Return the closest multiple of alignment that is less than or equal to value.

Constraints:

Will raise an exception if the alignment is zero.

Args:

• value (Int): The value to align.
• alignment (Int): Value to align to.

Returns:

Closest multiple of the alignment that is less than or equal to the input value. In other words, floor(value / alignment) * alignment.

## align_up

align_up(value: Int, alignment: Int) -> Int

Return the closest multiple of alignment that is greater than or equal to value.

Constraints:

Will raise an exception if the alignment is zero.

Args:

• value (Int): The value to align.
• alignment (Int): Value to align to.

Returns:

Closest multiple of the alignment that is greater than or equal to the input value. In other words, ceiling(value / alignment) * alignment.

## all_true

all_true[simd_width: Int](val: SIMD[bool, simd_width]) -> Bool

Returns True if all elements in the SIMD vector are True and False otherwise.

Parameters:

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

Args:

• val (SIMD[bool, simd_width]): The SIMD vector to reduce.

Returns:

True if all values in the SIMD vector are True and False otherwise.

## any_true

any_true[simd_width: Int](val: SIMD[bool, simd_width]) -> Bool

Returns True if any elements in the SIMD vector is True and False otherwise.

Parameters:

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

Args:

• val (SIMD[bool, simd_width]): The SIMD vector to reduce.

Returns:

True if any values in the SIMD vector is True and False otherwise.

## asin

asin[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the asin of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The asin of the input.

## asinh

asinh[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the asinh of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The asinh of the input.

## atan

atan[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the atan of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The atan of the input.

## atan2

atan2[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the atan2 of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The atan2 of the inputs.

## atanh

atanh[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the atanh of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The atanh of the input.

## cbrt

cbrt[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the cbrt of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The cbrt of the input.

## ceil

ceil[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise ceiling on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform ceiling on.

Returns:

The elementwise ceiling of x.

## clamp

clamp[simd_width: Int, type: DType](x: SIMD[type, simd_width], lower_bound: SIMD[type, simd_width], upper_bound: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Clamp the values in a SIMD vector to be in a certain range.

Clamp cuts values in the input SIMD vector off at the upper bound and lower bound values. For example, SIMD vector [0, 1, 2, 3] clamped to a lower bound of 1 and an upper bound of 2 would return [1, 1, 2, 2].

Parameters:

• simd_width (Int): Width of the input SIMD vectors.
• type (DType): DType of the input SIMD vectors.

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform the clamp operation on.
• lower_bound (SIMD[type, simd_width]): Minimum of the range to clamp to.
• upper_bound (SIMD[type, simd_width]): Maximum of the range to clamp to.

Returns:

A new SIMD vector containing x clamped to be within lower_bound and upper_bound.

## copysign

copysign[simd_width: Int, type: DType](magnitude: SIMD[type, simd_width], sign: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Returns a value with the magnitude of the first operand and the sign of the second operand.

Parameters:

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

Args:

• magnitude (SIMD[type, simd_width]): The magnitude to use.
• sign (SIMD[type, simd_width]): The sign to copy.

Returns:

Copies the sign from sign to magnitude.

## cos

cos[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the cos of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The cos of the input.

## cosh

cosh[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the cosh of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The cosh of the input.

## div

div[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise division of two SIMD vectors.

Parameters:

• simd_width (Int): Width of the input SIMD vectors.
• type (DType): DType of the input SIMD vectors.

Args:

• x (SIMD[type, simd_width]): SIMD vector containing the dividends.
• y (SIMD[type, simd_width]): SIMD vector containing the quotients.

Returns:

Elementwise division of SIMD vector x by SIMD vector y (this is x / y).

## div_ceil

div_ceil(numerator: Int, denominator: Int) -> Int

Divide an integer by another integer, and round up to the nearest integer.

Constraints:

Will raise an exception if denominator is zero.

Args:

• numerator (Int): The numerator.
• denominator (Int): The denominator.

Returns:

The ceiling of numerator divided by denominator.

## equal

equal[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are equal to values in y.

An element of the result SIMD vector will be True if the corresponding element in x is equal to the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is equal to the corresponding element in y, otherwise False.

## erf

erf[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Perform the elementwise Erf on a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform elementwise Erf on.

Returns:

The result of the elementwise Erf operation.

## erfc

erfc[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the erfc of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The erfc of the input.

## exp

exp[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Calculate elementwise e^{X_i}, where X_i is an element in the input SIMD vector at position i.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): The input SIMD vector.

Returns:

A SIMD vector containing e raised to the power Xi where Xi is an element in the input SIMD vector.

## exp2

exp2[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes elementwise 2 raised to the power of n, where n is an element of the input SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform exp2 on.

Returns:

Vector containing $$2^n$$ computed elementwise, where n is an element in the input SIMD vector.

## expm1

expm1[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the expm1 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The expm1 of the input.

## factorial

factorial(n: Int) -> Int

Compute the factorial of the integer.

Args:

• n (Int): The input value.

Returns:

The factorial of the input.

## floor

floor[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise floor on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform floor on.

Returns:

The elementwise floor of x.

## fma

fma(a: Int, b: Int, c: Int) -> Int

Perform fma (fused multiply-add) on the inputs.

The result is (a * b) + c.

Args:

• a (Int): The first input.
• b (Int): The second input.
• c (Int): The third input.

Returns:

(a * b) + c.

fma[simd_width: Int, type: DType](a: SIMD[type, simd_width], b: SIMD[type, simd_width], c: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Perform elementwise fma (fused multiply-add) on the inputs.

Each element in the result SIMD vector is $$(A_i * B_i) + C_i$$, where $$A_i$$, $$B_i$$ and $$C_i$$ are elements at index $$i$$ in a, b, and c respectively.

Parameters:

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

Args:

• a (SIMD[type, simd_width]): The first vector of inputs.
• b (SIMD[type, simd_width]): The second vector of inputs.
• c (SIMD[type, simd_width]): The third vector of inputs.

Returns:

Elementwise fma of a, b and c.

## frexp

frexp[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> StaticTuple[2, SIMD[type, simd_width]]

Break floating point values into a fractional part and an exponent part.

Constraints:

type must be a floating point value.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): The input values.

Returns:

A tuple of two SIMD vectors containing the fractional and exponent parts of the input floating point values.

## gcd

gcd(a: Int, b: Int) -> Int

Compute the greatest common divisor of two integers.

Constraints:

The inputs must be non-negative integers.

Args:

• a (Int): The first input argument.
• b (Int): The second input argument.

Returns:

The gcd of the inputs.

## greater

greater[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are greater than values in y.

An element of the result SIMD vector will be True if the corresponding element in x is greater than the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is greater than the corresponding element in y, otherwise False.

## greater_equal

greater_equal[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are greater than or equal to values in y.

An element of the result SIMD vector will be True if the corresponding element in x is greater than or equal to the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is greater than or equal to the corresponding element in y, otherwise False.

## hypot

hypot[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the hypot of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The hypot of the inputs.

## identity

identity[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Identity of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): The SIMD vector to take identity of.

Returns:

Identity of x, which is x.

## iota

iota[simd_width: Int, type: DType]() -> SIMD[type, simd_width]

Create a SIMD vector containing an increasing sequence, starting from 0.

Parameters:

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

Returns:

An increasing sequence of values, starting from 0.

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

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

Parameters:

• simd_width (Int): The width of the input and output SIMD vector.
• type (DType): The dtype 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.

## is_even

is_even(val: Int) -> Bool

Elementwise check of whether an integer value is even.

Args:

• val (Int): The int value to check.

Returns:

True if the input is even and False otherwise.

is_even[simd_width: Int, type: DType](val: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether SIMD vector contains even values.

An element of the result SIMD vector will be True if the value is even, and False otherwise.

Parameters:

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

Args:

• val (SIMD[type, simd_width]): The SIMD vector to check.

Returns:

A SIMD vector containing True if the corresponding element in val is even, otherwise False.

## is_odd

is_odd(val: Int) -> Bool

Elementwise check of whether an integer value is odd.

Args:

• val (Int): The int value to check.

Returns:

True if the input is odd and False otherwise.

is_odd[simd_width: Int, type: DType](val: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether SIMD vector contains odd values.

An element of the result SIMD vector will be True if the value is odd, and False otherwise.

Parameters:

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

Args:

• val (SIMD[type, simd_width]): The SIMD vector to check.

Returns:

A SIMD vector containing True if the corresponding element in val is odd, otherwise False.

## is_power_of_2

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

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:

• simd_width (Int): The width of the input and output SIMD vector.
• type (DType): The dtype of the input 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

Check 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.

## isclose

isclose[simd_width: Int, type: DType](a: SIMD[type, simd_width], b: SIMD[type, simd_width], absolute_tolerance: SIMD[type, 1], relative_tolerance: SIMD[type, 1]) -> SIMD[bool, simd_width]

Checks if the two input values are numerically within a tolerance.

When the type is integral, then equality is checked. When the type is floating point, then this checks if the two input values are numerically the close using the $$abs(a - b) <= max(rtol * max(abs(a), abs(b)), atol)$$ formula.

Unlike Pythonsâ€™s math.isclose, this implementation is symmetric. I.e. isclose(a,b) == isclose(b,a).

Parameters:

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

Args:

• a (SIMD[type, simd_width]): The first value to compare.
• b (SIMD[type, simd_width]): The second value to compare.
• absolute_tolerance (SIMD[type, 1]): The absolute tolerance.
• relative_tolerance (SIMD[type, 1]): The relative tolerance.

Returns:

A boolean vector where a and b are equal within the specified tolerance.

isclose[simd_width: Int, type: DType](a: SIMD[type, simd_width], b: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Checks if the two input values are numerically within tolerance, with atol=1e-08 and rtol=1e-05.

When the type is integral, then equality is checked. When the type is floating point, then this checks if the two input values are numerically the close using the abs(a - b) <= max(rtol * max(abs(a), abs(b)), atol) formula. The default absolute and relative tolerances are picked from the numpy default values.

Parameters:

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

Args:

• a (SIMD[type, simd_width]): The first value to compare.
• b (SIMD[type, simd_width]): The second value to compare.

Returns:

A boolean vector where a and b are equal within tolerance, with atol=1e-08 and rtol=1e-05.

## j0

j0[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the j0 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The j0 of the input.

## j1

j1[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the j1 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The j1 of the input.

## lcm

lcm(a: Int, b: Int) -> Int

Compute the least common divisor of two integers.

Constraints:

The inputs must be non-negative integers.

Args:

• a (Int): The first input argument.
• b (Int): The second input argument.

Returns:

The lcm of the inputs.

## ldexp

ldexp[simd_width: Int, type: DType](x: SIMD[type, simd_width], exp: SIMD[si32, simd_width]) -> SIMD[type, simd_width]

Compute elementwise ldexp function.

The ldexp function multiplies a floating point value x by the number 2 raised to the exp power. I.e. $$ldexp(x,exp)$$ calculate the value of $$x * 2^{exp}$$ and is used within the $$erf$$ function.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector of floating point values.
• exp (SIMD[si32, simd_width]): SIMD vector containing the exponents.

Returns:

Vector containing elementwise result of ldexp on x and exp.

## less

less[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are less than values in y.

An element of the result SIMD vector will be True if the corresponding element in x is less than the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is less than the corresponding element in y, otherwise False.

## less_equal

less_equal[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are less than or equal to values in y.

An element of the result SIMD vector will be True if the corresponding element in x is less than or equal to the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is less than or equal to the corresponding element in y, otherwise False.

## lgamma

lgamma[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the lgamma of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The lgamma of the input.

## log

log[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise log (base 10) of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): Vector to perform logarithm operation on.

Returns:

Vector containing result of performing log base 10 on x.

## log10

log10[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the log10 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The log10 of the input.

## log1p

log1p[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the log1p of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The log1p of the input.

## log2

log2[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise log (base 2) of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): Vector to perform logarithm operation on.

Returns:

Vector containing result of performing log base 2 on x.

## logb

logb[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the logb of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The logb of the input.

## max

max(x: Int, y: Int) -> Int

Maximum of two integers.

Args:

• x (Int): Integer input to max.
• y (Int): Integer input to max.

Returns:

Maximum of x and y.

max[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise maximum of x and y.

An element of the result SIMD vector will be the maximum of the corresponding elements in x and y.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector.
• y (SIMD[type, simd_width]): Second SIMD vector.

Returns:

A SIMD vector containing the elementwise maximum of x and y.

## min

min(x: Int, y: Int) -> Int

Minimum of two integers.

Args:

• x (Int): Integer input to max.
• y (Int): Integer input to max.

Returns:

Minimum of x and y.

min[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise minimum of x and y.

An element of the result SIMD vector will be the minimum of the corresponding elements in x and y.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector.
• y (SIMD[type, simd_width]): Second SIMD vector.

Returns:

A SIMD vector containing the elementwise minimum of x and y.

## mul

mul[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise multiplication of two SIMD vectors.

Parameters:

• simd_width (Int): Width of the input SIMD vectors.
• type (DType): DType of the input SIMD vectors.

Args:

• x (SIMD[type, simd_width]): First SIMD vector to multiply.
• y (SIMD[type, simd_width]): Second SIMD vector to multiply.

Returns:

Elementwise multiplication of x and y.

## nearbyint

nearbyint[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the nearbyint of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The nearbyint of the input.

## nextafter

nextafter[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the nextafter of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The nextafter of the inputs.

## none_true

none_true[simd_width: Int](val: SIMD[bool, simd_width]) -> Bool

Returns True if all element in the SIMD vector are False and False otherwise.

Parameters:

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

Args:

• val (SIMD[bool, simd_width]): The SIMD vector to reduce.

Returns:

True if all values in the SIMD vector are False and False otherwise.

## not_equal

not_equal[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[bool, simd_width]

Elementwise check of whether values in x are not equal to values in y.

An element of the result SIMD vector will be True if the corresponding element in x is not equal to the corresponding element in y, and False otherwise.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): First SIMD vector to compare.
• y (SIMD[type, simd_width]): Second SIMD vector to compare.

Returns:

A SIMD vector containing True if the corresponding element in x is not equal to the corresponding element in y, otherwise False.

## pow

pow[simd_width: Int, lhs_type: DType, rhs_type: DType](lhs: SIMD[lhs_type, simd_width], rhs: SIMD[rhs_type, simd_width]) -> SIMD[lhs_type, simd_width]

Computes elementwise power of a floating point type raised to another floating point type.

An element of the result SIMD vector will be the result of raising the corresponding element of lhs to the corresponding element of rhs.

Constraints:

rhs_type and lhs_type must be the same, and must be floating point types.

Parameters:

• simd_width (Int): The width of the input and output SIMD vectors.
• lhs_type (DType): The dtype of the lhs SIMD vector.
• rhs_type (DType): The dtype of the rhs SIMD vector.

Args:

• lhs (SIMD[lhs_type, simd_width]): Base of the power operation.
• rhs (SIMD[rhs_type, simd_width]): Exponent of the power operation.

Returns:

A SIMD vector containing elementwise lhs raised to the power of rhs.

pow[simd_width: Int, lhs_type: DType, rhs_type: DType](lhs: SIMD[lhs_type, simd_width], rhs: SIMD[rhs_type, simd_width]) -> SIMD[lhs_type, simd_width]

Computes the elementwise power where the exponent is an integer.

Constraints:

rhs_type must be an integral type.

Parameters:

• simd_width (Int): The width of the input and output SIMD vectors.
• lhs_type (DType): The dtype of the lhs SIMD vector.
• rhs_type (DType): The dtype of the rhs SIMD vector.

Args:

• lhs (SIMD[lhs_type, simd_width]): Base of the power operation.
• rhs (SIMD[rhs_type, simd_width]): Exponent of the power operation.

Returns:

A SIMD vector containing elementwise lhs raised to the power of rhs.

pow[simd_width: Int, lhs_type: DType, rhs_type: DType](lhs: SIMD[lhs_type, simd_width], rhs: SIMD[rhs_type, simd_width]) -> SIMD[lhs_type, simd_width]

Elementwise power of an integer raised to a floating point type. This implementation of pow is unsupported.

Constraints:

rhs_type must be a floating point type, while lhs_type must be an integral type.

Parameters:

• simd_width (Int): The width of the input and output SIMD vectors.
• lhs_type (DType): The dtype of the lhs SIMD vector.
• rhs_type (DType): The dtype of the rhs SIMD vector.

Args:

• lhs (SIMD[lhs_type, simd_width]): Base of the power operation.
• rhs (SIMD[rhs_type, simd_width]): Exponent of the power operation.

Returns:

A SIMD vector containing elementwise lhs raised to the power of rhs.

pow[n: Int, type: DType, simd_width: Int](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the elementwise power where the exponent is an integer known at compile time.

Constraints:

n must be a signed si32 type.

Parameters:

• n (Int): Exponent of the power operation.
• type (DType): The dtype of the x SIMD vector.
• simd_width (Int): The width of the input and output SIMD vectors.

Args:

• x (SIMD[type, simd_width]): Base of the power operation.

Returns:

A SIMD vector containing elementwise x raised to the power of n.

pow[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the pow of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The pow of the inputs.

pow[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: Int) -> SIMD[type, simd_width]

Computes the pow of the inputs.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (Int): The second input argument.

Returns:

The pow of the inputs.

## reciprocal

reciprocal[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Take the elementwise reciprocal of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): The SIMD vector to perform elementwise reciprocal on.

Returns:

A SIMD vector the elementwise reciprocal of x.

## reduce_bit_count

reduce_bit_count[simd_width: Int, type: DType](val: SIMD[type, simd_width]) -> Int

Return scalar containing total number of bits set in given vector.

Constraints:

The input must be either integral or boolean type.

Parameters:

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

Args:

• val (SIMD[type, simd_width]): The SIMD vector to reduce.

Returns:

Count of set bits across all elements of the vector.

## remainder

remainder[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the remainder of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The remainder of the inputs.

## rint

rint[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the rint of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The rint of the input.

## round

round[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the round of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The round of the input.

## rsqrt

rsqrt[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise reciprocal square root on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform reciprocal square root on.

Returns:

The elementwise reciprocal square root of x.

## scalb

scalb[simd_width: Int, type: DType](arg0: SIMD[type, simd_width], arg1: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the scalb of the inputs.

Constraints:

The inputs must be of floating point type.

Parameters:

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

Args:

• arg0 (SIMD[type, simd_width]): The first input argument.
• arg1 (SIMD[type, simd_width]): The second input argument.

Returns:

The scalb of the inputs.

## sin

sin[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the sin of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The sin of the input.

## sinh

sinh[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the sinh of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The sinh of the input.

## sqrt

sqrt[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise square root on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform square root on.

Returns:

The elementwise square root of x.

## sub

sub[simd_width: Int, type: DType](x: SIMD[type, simd_width], y: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise subtraction of two SIMD vectors.

Parameters:

• simd_width (Int): Width of the input SIMD vectors.
• type (DType): DType of the input SIMD vectors.

Args:

• x (SIMD[type, simd_width]): SIMD vector which y will be subtracted from.
• y (SIMD[type, simd_width]): SIMD vector to subract from x.

Returns:

Elementwise subtraction of SIMD vector y from SIMD vector x (this is x - y).

## tan

tan[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the tan of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The tan of the input.

## tanh

tanh[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Elementwise evaluation of the tanh function.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): The vector to perform the elementwise tanh on.

Returns:

The result of the elementwise tanh operation.

## tgamma

tgamma[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the tgamma of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The tgamma of the input.

## trunc

trunc[simd_width: Int, type: DType](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Performs elementwise truncation on the elements of a SIMD vector.

Parameters:

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

Args:

• x (SIMD[type, simd_width]): SIMD vector to perform trunc on.

Returns:

The elementwise truncation of x.

## y0

y0[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the y0 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The y0 of the input.

## y1

y1[simd_width: Int, type: DType](arg: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Computes the y1 of the inputs.

Constraints:

The input must be of floating point type.

Parameters:

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

Args:

• arg (SIMD[type, simd_width]): The input argument.

Returns:

The y1 of the input.