
On Fri, Aug 26, 2011 at 5:16 AM, alfC
On Friday, August 26, 2011 1:13:37 AM UTC-7, John Maddock wrote:
Plus I don't really want to make Boost.Math dependent upon Boost.Units.
(of course but) This is a chicken and egg problem. Maybe this is calling for a third library that provides a uniform protocol for determining the type results of operators. Maybe based on boost/units/operator_helpers? Maybe it already exists? Maybe it is a matter of adding result_type/result_of protocol to the equivalent of std::multiplies
? There is always "decltype" but I don't know what is the philosophy with respect to C++11 features. Another alternative is to have an optional extra template argument that provides information on the types. Just take boost.units as an example; there can be other numeric types in which T*T != T and yet all these algorithms still make sense. Again, nobody is asking that make Boost.Math dependent on Boost.Units; just make it compatible with it by not doing over assumptions on the types. Boost.Units quantities are really very honest mathematical objects, it is not just a weird designed type. I am sure Boost.Units authors can make a better case.
I don't think it has to be a chicken and egg problem. If the math library says that it is generic it should support return types that are different from the input types IMHO. In the past I have implemented math libraries like so: template < typename X0, typename Y0, typename Z0, typename X1, typename Y1, typename Z1
BOOST_TYPEOF_TPL(X0() * X1() + Y0() * Y1() + Z0() * Z1())
dot_product(const vector3