IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
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).

fma

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

Performs 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:

Int: (a * b) + c.

fma[dtype: DType, width: Int, //](a: SIMD[dtype, width], b: SIMD[dtype, width], c: SIMD[dtype, width]) -> SIMD[dtype, width]

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

Each element in the result SIMD vector is (AiBi)+Ci(A_i * B_i) + C_i, where AiA_i, BiB_i and CiC_i are elements at index ii in a, b, and c respectively.

Parameters:

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

Args:

Returns:

SIMD[dtype, width]: Elementwise fma of a, b and c.