WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ecd847f

Browse files
committed
Reenable fma
1 parent 4578701 commit ecd847f

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

include/boost/units/cmath.hpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ fdim BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit,Y>& q1,
231231
return quantity_type::from_value(fdim BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value()));
232232
}
233233

234-
#if 0
235234

236235
template<class Unit1,class Unit2,class Unit3,class Y>
237236
inline
@@ -240,10 +239,11 @@ typename add_typeof_helper<
240239
typename multiply_typeof_helper<quantity<Unit1,Y>,
241240
quantity<Unit2,Y> >::type,
242241
quantity<Unit3,Y> >::type
243-
fma BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit1,Y>& q1,
244-
const quantity<Unit2,Y>& q2,
245-
const quantity<Unit3,Y>& q3)
242+
fma (const quantity<Unit1,Y>& q1,
243+
const quantity<Unit2,Y>& q2,
244+
const quantity<Unit3,Y>& q3)
246245
{
246+
using std::fma;
247247
using namespace detail;
248248

249249
typedef quantity<Unit1,Y> type1;
@@ -253,10 +253,33 @@ fma BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity<Unit1,Y>& q1,
253253
typedef typename multiply_typeof_helper<type1,type2>::type prod_type;
254254
typedef typename add_typeof_helper<prod_type,type3>::type quantity_type;
255255

256-
return quantity_type::from_value(fma BOOST_PREVENT_MACRO_SUBSTITUTION (q1.value(),q2.value(),q3.value()));
256+
return quantity_type::from_value(fma(q1.value(),q2.value(),q3.value()));
257+
}
258+
259+
template<class Unit, class Y>
260+
inline
261+
BOOST_CONSTEXPR
262+
quantity<Unit,Y>
263+
fma(const Y& q1,
264+
const quantity<Unit,Y>& q2,
265+
const quantity<Unit,Y>& q3)
266+
{
267+
using std::fma;
268+
return quantity<Unit,Y>::from_value(fma(q1,q2.value(),q3.value()));
269+
}
270+
271+
template<class Unit, class Y>
272+
inline
273+
BOOST_CONSTEXPR
274+
quantity<Unit,Y>
275+
fma(const quantity<Unit, Y>& q1,
276+
const Y& q2,
277+
const quantity<Unit,Y>& q3)
278+
{
279+
using std::fma;
280+
return quantity<Unit,Y>::from_value(fma(q1.value(),q2,q3.value()));
257281
}
258282

259-
#endif
260283

261284
template<class Unit,class Y>
262285
inline

test/test_cmath.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ int main()
107107
BOOST_CONSTEXPR_OR_CONST bu::quantity<bu::area> A1(4.0*bu::square_meters),
108108
A2(L1*L2+A1);
109109

110-
#if 0
111-
BOOST_TEST((bu::fma)(L1,L2,A1) == A2);
112-
#endif
110+
BOOST_TEST(bu::fma(L1,L2,A1) == A2);
111+
BOOST_TEST(bu::fma(2.0, L1, L2) == 2.0*L1 + L2);
112+
BOOST_TEST(bu::fma(L1, 2.0, L2) == 2.0*L1 + L2);
113113

114114
BOOST_TEST((bu::fmax)(E4,E5) == E5);
115115
BOOST_TEST((bu::fmin)(E4,E5) == E4);

0 commit comments

Comments
 (0)