|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2006-08-20 11:34:12
"Matthias Troyer"
>
> On Aug 19, 2006, at 2:04 PM, Andy Little wrote:
>
>>
>> "Matthias Troyer" <troyer_at_[hidden]> wrote in message
>> news:09128591-A3C8-4432-A934-9C01B9042AF7_at_itp.phys.ethz.ch...
>>> Andy little wrote
<...>
>> force = mass * acceleration;
>>
>> M = mass
>> L = length
>> T = time;
>>
>> force == M * L / T^2
>> acceleration = L/T^2
>>
>> Therefore (M* L/T^2) = (M) * ( L/ T^2)
>>
>> In this case its just dimensional math, no value is involved.
>
> This is just a check of units. I would prefer calling them units and
> not quantities.
Having had correspondence from various people, I am now fairly sure that the
Americans have a different concept of a unit than (at least) Europeans.
<...>
>>> Does this mean that the name will be derived, like in m/s^2 ?
>>
>> Yes.
>>
>> Or that
>>> there is no unit symbol at all that can be printed?
>>
>> No, it defaults to something like the above for an anonymous quantity.
>
> ok, so named quantity has a special unit symbol, and anonymous
> quantity a default unit symbol?
Basically the output routine interrogates the StaticUnit as to whether its a
named quantity.
If not then it basically spews out a list of non zero dimensions. There are some
other complexities but that is the gist of it.
In case of named quantities it looks at The named quantity traits class. Si
quantities have some manipulations done to provide a prefix which is then
applied to a symbol which is in the traits class.
For Non SI named quantities it is assumed that there is an output overload for
that particular unit . No formula can be applied by definition as these are just
a rag bag of odd units with funny names, which the SI system wants to get rid of
anyway.
>> The programmer can 'name' a quantity by assigning or initialising a
>> named
>> quantity from an anonymous quantity, when they need to be explicit
>> about what
>> quantity it represents.
>
> Wait, if I multiply quantities (which have units) then also the
> result will have a unit. E.g. if I divide 10 meters by 2 seconds then
> I get 5 m/s . I wouldn't call that anonymous since I know the unit: m/s
It would be possible to try to predict a named quantity result of a calculation
for some cases, but it would add a lot of complexity, and I am fairly confident
that the prediction would be wrong in some cases and not possible in others. I
took the simple option and decided not to bother even to try to guess. ( In
fact the rules are somewhat more complicated, for example Q+Q --> Q does
return what went in, etc, but you would need to read the docs in some detail )
The programmer will know which quantity they want,
when they want to be specific, and in many cases of temporaries it isnt really
important. The main use of named quantities is for 'pretty' output.
>> fixed_quantity<StaticUnit,NumericType>
>>
>> (A Static Unit is just a Unit where all the data is available at
>> compile time.)
>
> OK, this sounds reasonable enough, except that I'm still confused
> what exactly an anonymous quantity is.
The distinction between a named quantity and an anonymous quantity is really
only important for input/output purposes, but that isnt trivial.One area I would
like to investigate is trying to get Quan to output STEP files
http://en.wikipedia.org/wiki/ISO_10303 which I have been told Quan would be
very suitable for. Unfortunately the Spec looks to be quite expensive though, so
I don't know very much about it.
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk