Fused multiply-add (with a single rounding) for Python

Fused multiply-add for Python.

Fused multiply-add computes (x*y) + z with a single rounding. Useful for dot
products, matrix multiplications, polynomial evaluations (e.g., with Horner’s rule),
Newton’s method for evaluating functions, convolutions, artificial neural networks etc.

Use as

import pyfma

out = pyfma.fma(3.0, 2.0, 1.0)  # 3.0*2.0 + 1.0 = 7.0

Also works with NumPy inputs:

import numpy
import pyfma

x = numpy.random.rand(3, 4, 5)
y = numpy.random.rand(3, 4, 5)
z = numpy.random.rand(3, 4, 5)

out = pyfma.fma(x, y, z)

Built with pybind11.

Caution
The C/C++ implementation of FMA in MS Windows is reportedly
broken. Use with care.

Installation

pyfma can be installed from the Python Package
Index, so with

pip install pyfma

you can install/upgrade.

Manual installation

For manual installation (if you’re a developer or just really keen on getting the
bleeding edge

 

 

 

To finish reading, please visit source site