
On Aug 23, 2006, at 8:40 PM, Andy Little wrote:
"Matthias Troyer" <troyer@itp.phys.ethz.ch> wrote in message news:14AD1E01-8077-42A7-A25E-5B5AF8AB1EFA@itp.phys.ethz.ch...
I have a question here: what is the purpose of these named quantities - is it to output J instead of kgm^2s^2 for energy and Nm instead of kgm^2s^2 for torque?
Basically yes. Way back someone requested that they be differentiated, so I differentiated them and hence (BTW) the notion of an anonymous quantity was born as a logical result of not being able to distinguish the two in some cases.
After all torque is a vector quantity and energy is a scalar quantity, so they are quite different. One could output energy units as N.m , but the joule is the more well known SI energy unit, so it helps to put things in a familiar context.
Also there are various non SI units which specifically mean torque, such as (reading from the SI manual) dyne centimeter, kilogram-force meter, etc.
And for energy: erg per square centimeter second, watt per square inch etc..
OK, to be able to output specific unit symbols is a good thing.
- is it to prevent adding energy and torque?
It could be in Quan, by more querying of the unit and disallowing the calculation in this case. At one point Quan (in a previous incarnation) did do this, but then maybe there are situations where adding or comparing torque and energy is appropriate, so I opted for the freer semantics. If there is a proof of some sort that they can never be compared or added then I will change the current semantics, but I am not enough of an expert to say for sure.
I am strictly against any disallowing of calculations. Just consider the following pseudo code (I do not refer to any specific implementation but hope the types are self-explanatory unit::force::N force; unit::length::m distance; unit::energy::J energy; unit::torque::Nm torque; energy = force*distance; // should this be allowed? torque = force*distance; // should this be allowed? I think that in both cases the implicit conversion from the (annonymous?) quantity force*distance to either energy or torque. I think that to make the library usable one needs to allow these conversions. If one want to prevent the operations then because one is a vector scalar product (the energy) and the other a vector cross product (the torque) then this should be done at the level of the value_type of the quantity and not at the unit level. Matthias