|
Boost : |
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2008-02-03 13:39:16
On Feb 3, 2008 1:28 PM, Bruno Lalande <bruno.lalande_at_[hidden]> wrote:
> I can write tests and docs for you, as well as study the different
> performance / optimization aspects with some other compilers. As I've never
> done this before, I'll have to read the different guidelines describing the
> way in which such contributions have to be made, so it can take a few days.
> But I think we're not in a hurry.
>
> Steven, could you tell me if some aspects of the implementation you made for
> Boost.Unit are better than mine? This would permit to be sure to have the
> best implementation in Boost.Math.
>
I've usually seen it described like this:
template <int N>
struct positive_power
{
template <typename T>
static float result(T base)
{
return (N%2) ? positive_power<1>::result(base)
* positive_power<N-1>::result(base)
: positive_power<2>::result(
positive_power<N/2>::result(base)
);
}
};
I have no idea whether that would work better or not. It would mean
more template instantiations, of course, but avoiding storing it in a
named temporary might make the optimizer happier. (Are there
provisions for allowing different temporary sizes in floating point
math? I seem to recall a flag for gcc that forces storing all the
intermediate results to prevent this, so there might be.) I'd also
wonder whether -ffast-math or similar flags make a difference.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk