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).
pow
def pow(base: SIMD, exp: SIMD) -> SIMD[base.dtype, base.length]
Computes the base raised elementwise to the power of the exp.
For an integral base, a negative exponent aborts.
Constraints:
The exp must have the same dtype and width as the base, or be a
scalar. An integral base requires an integral exp.
Args:
Returns:
SIMD[base.dtype, base.length]: The base raised elementwise to the power of the exp.
def pow(base: SIMD, exp: FloatLiteral) -> SIMD[base.dtype, base.length]
Computes the base raised elementwise to the power of a float literal.
Constraints:
The base must be floating point.
Args:
- base (
SIMD): The base of the power operation. - exp (
FloatLiteral): The exponent, converted to the dtype ofbase.
Returns:
SIMD[base.dtype, base.length]: The base raised elementwise to the power of the exp.
def pow[dtype: DType, width: SIMDLength, //](base: SIMD[dtype, width], exp: SIMD[dtype, width], mod: SIMD[dtype, width]) -> SIMD[dtype, width] where dtype.is_integral()
Computes base raised to the power of exp, modulo mod, elementwise.
For example, pow(3, 4, 5) is 1, pow(2, 3, -5) is -2, and
pow(3, -1, 7) is 5, because 3 * 5 % 7 == 1.
Constraints:
The dtype must be an integral type of at most 64 bits.
Parameters:
- dtype (
DType): Thedtypeof the inputs and the result. - width (
SIMDLength): The width of the inputs and the result.
Args:
- base (
SIMD[dtype, width]): The base of the power operation. - exp (
SIMD[dtype, width]): The exponent of the power operation. - mod (
SIMD[dtype, width]): The modulus.
Returns:
SIMD[dtype, width]: The base raised to the power of exp, modulo mod. Aborts if
mod is zero, or if exp is negative and base has no inverse
modulo mod.