diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2017-01-21 12:35:30 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2017-01-21 12:35:30 (GMT) |
commit | d1b230e48b81eb90d10f0ceb4e34c547800bd3a8 (patch) | |
tree | bb7cfe1f084957c978a105111f7345dddecd695d /Modules/clinic | |
parent | 502efda10c6ec54ba9f0d490264b785971b2b6cc (diff) | |
download | cpython-d1b230e48b81eb90d10f0ceb4e34c547800bd3a8.zip cpython-d1b230e48b81eb90d10f0ceb4e34c547800bd3a8.tar.gz cpython-d1b230e48b81eb90d10f0ceb4e34c547800bd3a8.tar.bz2 |
Issue #29282: add fused multiply-add function, math.fma.
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/mathmodule.c.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index 84a7a70..4e9fe20 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -80,6 +80,40 @@ PyDoc_STRVAR(math_factorial__doc__, #define MATH_FACTORIAL_METHODDEF \ {"factorial", (PyCFunction)math_factorial, METH_O, math_factorial__doc__}, +PyDoc_STRVAR(math_fma__doc__, +"fma($module, x, y, z, /)\n" +"--\n" +"\n" +"Fused multiply-add operation. Compute (x * y) + z with a single round."); + +#define MATH_FMA_METHODDEF \ + {"fma", (PyCFunction)math_fma, METH_FASTCALL, math_fma__doc__}, + +static PyObject * +math_fma_impl(PyObject *module, double x, double y, double z); + +static PyObject * +math_fma(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + double x; + double y; + double z; + + if (!_PyArg_ParseStack(args, nargs, "ddd:fma", + &x, &y, &z)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("fma", kwnames)) { + goto exit; + } + return_value = math_fma_impl(module, x, y, z); + +exit: + return return_value; +} + PyDoc_STRVAR(math_trunc__doc__, "trunc($module, x, /)\n" "--\n" @@ -536,4 +570,4 @@ math_isclose(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna exit: return return_value; } -/*[clinic end generated code: output=71806f73a5c4bf0b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f428e1075d00c334 input=a9049054013a1b77]*/ |