|
Boost : |
From: Matthias Schabel (boost_at_[hidden])
Date: 2007-04-05 13:00:00
Steven raised some good points about the dimensionless
specializations of quantities. The crux of the problem is that
sometimes we would like to be able to specify a formally
dimensionless quantity as a heterogeneous quantity : e.g.
1.0*CGS::dyne/SI::newton. If we automatically convert, we lose the
ability to represent quantities like this and all dimensionless
quantities become equivalent. However, in some cases you would like
to preserve the information on the unit system; for trig functions,
as an example, you would like to have closure so that
acos(cos(quantity<some_angular_unit,Y>))
returns the argument passed to cos. If system information is
stripped, this becomes impossible without explicitly specifying the
return type of acos. Furthermore, now we can't represent
dimensionless quantities for which conversion factors haven't been
defined. Now, if we preserve this capability, the system resulting
from a dimensionless unit such as 1.5*CGS::dyne/SI::newton becomes
ambiguous - should it be an SI dimensionless quantity or a CGS
dimensionless quantity. So, even though it is a bit ugly, I think
Steven is right that users will just need to explicitly cast
heterogeneous dimensionless quantities to homogeneous ones which are
well-defined and convertible to the underlying value_type...
1.0*CGS::dyne/SI::newton -> quantity< unit<dimensionless_type,[mixed
CGS/SI system]> >, not convertible to double
quantity<SI::dimensionless>(1.0*CGS::dyne/SI::newton) -> convertible
to double
At least this is consistent with the treatment of heterogeneous units
(which will be better documented any time now...) throughout the
remainder of the library...
Matthias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk