
Boost : 
From: John Maddock (john_at_[hidden])
Date: 20080205 11:56:54
Martin Bonner wrote:
>> The only use case I can think of is where the argument is an integer
>> rather than a real number (and the result is therefore a double),
>
> boost.units:
> pow<3>( length )
> is going to have units of volume.
Ah yes, forgot that. My gut feeling is that Boost.Math should concentrate
on the um... math: provide a nice simple implementation that's reasonably
efficient too. And libraries like Boost.Units can overload it for
dimentionedquantities, and use the Boost.Math version for the internal
calculation. Does this make sense?
> ... and I /believe/ that boost.units only needs half powers. So
> (modulu units)
>
> template<class T1, class T2, int N>
> T2 pow<N,2>(T1 val) { return sqrt(pow<N>(val)); }
>
> should do it.
>
> ... in fact, I suspect that boost.math pow should /only/ offer the
> integral powers, and boost.units should wrap it to add the rational
> support.
I guess the question is can we evaluate halfpowers more efficiently than
just using pow? Maybe, but it's not so obvious to me as it is for smallish
integer powers.
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk