Mojo function
exp_approx_f32
exp_approx_f32[W: Int](x: SIMD[DType.float32, W]) -> SIMD[DType.float32, W]
Computes a fast approximate e^x for SIMD vectors of 32-bit floats using the base-2 approximation as a backend.
This function converts the natural exponential input z to base-2 space
using the identity e^z = 2^(z * log2(e)), then calls the internal
_exp2_approx_f32 function to evaluate the FA-4 polynomial approximation
of 2^x. It is optimized for small SIMD widths and is fully inlined for
high performance.
Constraints:
The input must be a SIMD vector of 32-bit floating-point values.
Parameters:
- W (
Int): The width of the SIMD vector.
Args:
- x (
SIMD): The input SIMD vector representing the exponent.
Returns:
SIMD: A SIMD vector containing the approximate value of e^x.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!