diff --git a/pyopencl/cl/pyopencl-complex.h b/pyopencl/cl/pyopencl-complex.h index c33cbca0d334610956ab8cf99e6f1b869c656739..892b5868fb03820b0653c3740c0cdc4cb1938a8d 100644 --- a/pyopencl/cl/pyopencl-complex.h +++ b/pyopencl/cl/pyopencl-complex.h @@ -77,11 +77,11 @@ ; \ } \ \ - inline TP TPROOT##_muladd(TP a, TP b, TP c) \ + inline TP TPROOT##_fma(TP a, TP b, TP c) \ { \ return TPROOT##_new( \ - (c.real + a.real*b.real) - a.imag*b.imag, \ - (c.imag + a.real*b.imag) + a.imag*b.real); \ + fma(a.real, b.real, c.real) - a.imag*b.imag, \ + fma(a.imag, b.real, fma(a.real, b.imag, c.imag))); \ } \ \ inline TP TPROOT##_mul(TP a, TP b) \ diff --git a/test/test_clmath.py b/test/test_clmath.py index b640e0bbf979c9ed84139184ad5165513db48291..55d141947d3d493b4b73bb30f3d924ccaf89fe00 100644 --- a/test/test_clmath.py +++ b/test/test_clmath.py @@ -488,7 +488,7 @@ def test_complex_muladd(ctx_factory, dtype): ) {{ int gid = get_global_id(0); - res[gid] = c{real_type_name}_muladd(a[gid], b[gid], c[gid]); + res[gid] = c{real_type_name}_fma(a[gid], b[gid], c[gid]); }} """.format(real_type_name=real_type_name)