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).
scalb
def scalb[dtype: DType, width: SIMDLength, //](arg0: SIMD[dtype, width], arg1: SIMD[dtype, width]) -> SIMD[dtype, width] where dtype.is_floating_point()
Scales each value in arg0 by 2 raised to its exponent in arg1.
A finite, non-integral exponent produces NaN. A positive infinite
exponent produces infinity with the sign of arg0, except that a zero
base produces NaN. A negative infinite exponent produces zero with the
sign of arg0, except that an infinite base produces NaN. NaN arguments
produce NaN.
For example:
from std.math import scalb
var scaled = scalb(Float32(1.5), Float32(2.0))
Constraints:
The input must be a floating-point type. The float64 type is not
supported on Apple GPU.
Parameters:
- dtype (
DType): Thedtypeof the input and output SIMD vector. - width (
SIMDLength): The width of the input and output SIMD vector.
Args:
- arg0 (
SIMD[dtype, width]): The values to scale. - arg1 (
SIMD[dtype, width]): The base-2 exponents.
Returns:
SIMD[dtype, width]: The scaled values, computed elementwise.