Hi there,

Is this the implementation of fma?
https://github.com/nschloe/pyfma

Cheers,
Arnaldo

       .
       |\
     _/]_\_
~~~~~"~~~~~^~~~~~~~~~~~~~~~~~~~~~
Arnaldo D'Amaral Pereira Granja Russo
c i c l o t u x . o r g

2018-02-25 8:34 GMT-03:00 Nils Becker <nilsc.becker@gmail.com>:
Hey,
 
Anyone that understands FP better than I do:

In the above code, you are multiplying the step by an integer -- is there any precision loss when you do that??


Elementary operations (add, sub, mul, div) are demanded to be correctly rounded (cr) by IEEE, i.e. accurate within +/- 0.5 ulp. Consequently, a cr multiplication followed by a cr addition will be accurate within +/-1 ulp. This is also true if the first multiplicand is an integer.
Using FMA will reduce this to +/- 0.5 ulp. This increase in accuracy of the grid calculation should not be relevant - but it also does not hurt.

Still I would suggest adding the FMA operation to numpy, e.g. np.fma(a, b, c). There are several places in numpy that could benefit from the increased accuracy, e.g. evaluation of polynomials using Horner's method. In cases like this due to iteration and consequent error propagation the accuracy benefit of using FMA can be far larger. There may also be a performance benefit on platforms that implement FMA in hardware (although I am not sure about that).

Cheers
Nils

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion