fma in boost/units/cmath.hpp?
- Dominant language
- C++
- Stars
- 39
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
I've recently had a compile fail with `fma` on `boost::units` types. However, it appears this has been implemented in `boost/units/cmath.hpp`, but it has been explicitly disabled using an `#if 0`.
```
git show e634a7c6
commit e634a7c6bef7180ec34387fd7bb7c0236c17a990
Author: Steven Watanabe
Date: Sat Jun 7 17:15:24 2008 +0000
Remove compiler specific code from cmath. Disable functions which cannot be implemented easily using Boost.Math
[SVN r46217]
```
Is there any reason why we can't re-enable these code paths today?
Edit: I enabled those code paths, and it appears to be working. However, I had to add a couple other overloads:
```
template
inline
BOOST_CONSTEXPR
quantity
fma BOOST_PREVENT_MACRO_SUBSTITUTION (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 BOOST_PREVENT_MACRO_SUBSTITUTION (const quantity& q1,
const Y& q2,
const quantity& q3)
{
using std::fma;
return quantity::from_value(fma(q1.value(),q2,q3.value()));
}
```
I imagine the case where `a` and `x` have "inverse units" and `a*x+b` is dimensionless could also be supported.
Patchfile: [units_patch.txt](https://github.com/boostorg/units/files/11594479/units_patch.txt)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.