diff --git a/include/boost/units/cmath.hpp b/include/boost/units/cmath.hpp index da3da46f..94ae7f7b 100644 --- a/include/boost/units/cmath.hpp +++ b/include/boost/units/cmath.hpp @@ -231,7 +231,6 @@ fdim BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity& q1, return quantity_type::from_value(fdim BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value())); } -#if 0 template inline @@ -240,10 +239,11 @@ typename add_typeof_helper< typename multiply_typeof_helper, quantity >::type, quantity >::type -fma BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity& q1, - const quantity& q2, - const quantity& q3) +fma (const quantity& q1, + const quantity& q2, + const quantity& q3) { + using std::fma; using namespace detail; typedef quantity type1; @@ -253,10 +253,33 @@ fma BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity& q1, typedef typename multiply_typeof_helper::type prod_type; typedef typename add_typeof_helper::type quantity_type; - return quantity_type::from_value(fma BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value(),q3.value())); + return quantity_type::from_value(fma(q1.value(),q2.value(),q3.value())); +} + +template +inline +BOOST_CONSTEXPR +quantity +fma(const Y& q1, + const quantity& q2, + const quantity& q3) +{ + using std::fma; + return quantity::from_value(fma(q1,q2.value(),q3.value())); +} + +template +inline +BOOST_CONSTEXPR +quantity +fma(const quantity& q1, + const Y& q2, + const quantity& q3) +{ + using std::fma; + return quantity::from_value(fma(q1.value(),q2,q3.value())); } -#endif template inline diff --git a/test/test_cmath.cpp b/test/test_cmath.cpp index 8a25b4a8..f2c3f9d2 100644 --- a/test/test_cmath.cpp +++ b/test/test_cmath.cpp @@ -107,9 +107,9 @@ int main() BOOST_CONSTEXPR_OR_CONST bu::quantity A1(4.0*bu::square_meters), A2(L1*L2+A1); -#if 0 - BOOST_TEST((bu::fma)(L1,L2,A1) == A2); -#endif + BOOST_TEST(bu::fma(L1,L2,A1) == A2); + BOOST_TEST(bu::fma(2.0, L1, L2) == 2.0*L1 + L2); + BOOST_TEST(bu::fma(L1, 2.0, L2) == 2.0*L1 + L2); BOOST_TEST((bu::fmax)(E4,E5) == E5); BOOST_TEST((bu::fmin)(E4,E5) == E4);