[issue29282] Fused multiply-add: proposal to add math.fma()

Mark Dickinson report at bugs.python.org
Mon Jan 16 06:36:54 EST 2017


Mark Dickinson added the comment:

> The performance argument unlikely is applicable in this case.

Agreed. This is mainly about accuracy, not speed: the FMA operation is a fundamental building block for floating-point arithmetic, is useful in some numerical algorithms, and essential in others (especially when doing things like double-double arithmetic). It would be valuable to have when prototyping numerical algorithms in pure Python.

Given that it's supported in C99 and on current Windows, I'm +1 on including it in the math module.

Note that implementing this it not quite as straightforward as simply wrapping the libm version, since we'll also want the correct exceptional behaviour, for consistency with the rest of the math module: i.e., we should be raising ValueError where the fma operation would signal the invalid FPE, and OverflowError where the fma operation would signal the overflow FPE.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29282>
_______________________________________


More information about the Python-bugs-list mailing list