|
Boost : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-04 13:48:30
AMDG
Bruno Lalande wrote:
> Yes I think Boost.Math is the right place for this too. And Boost.Unit will
> be able to take it there instead of having it confined in a "units::details"
> or something, this way everybody can benefit of this useful thing.
>
> 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.
>
Your implementation seems to be faster in the few tests I ran on msvc 9.0.
It would be nice if boost::units::pow could be completely replaced by
this utility,
so here are the issues that would need to the covered:
* The result type is not necessarily going to be the same as the arguments
so it would need to use Boost.Typeof or some such.
* Rational exponents need to work, so I would need a way to specialize
the function to work with boost::units::static_rational. I would expect
the customization mechanism to look something like this:
struct default_value_tag;
template<class T>
struct pow_value_tag {
typedef default_value_tag tag;
};
template<class Exp>
struct pow_exponent_tag {
typedef typename Exp::tag type;
};
template<class ValueTag, class ExponentTag>
struct pow_impl;
template<class Value, class Exponent>
struct pow {
typedef typename pow_impl<
typename pow_value_tag<Value>::type,
typename pow_exponent_tag<Exponent>::type
>::template apply<Value, Exponent> impl;
typedef typename impl::type type;
static type call(const Value& v) {
return(impl::call(v));
}
};
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk