Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-08-19 08:04:37


"Matthias Troyer" <troyer_at_[hidden]> wrote in message
news:09128591-A3C8-4432-A934-9C01B9042AF7_at_itp.phys.ethz.ch...
> Andy little wrote
>> Eric leemings wrote
>>> Abstract quantity?
>>
>> An abstract quantity is a quantity without a numeric value or a
>> conversion
>> factor. It still conforms to dimensional analysis and dimensional
>> math.
>> In fact the abstract quantity concept (small c) has now been
>> gobbled up by the
>> all encompassing Static Unit concept.
>
> I am confused. What is a quantity without a numeric value? Just a unit?
> I don't see the reason for a quantity without a value. Just the name
> quantity implies a value.

I was taught at school to do dimensional analysis checks manually. For example

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.

FWIW AbstractQuantity isnt a Concept in the latest version of Quan, its just a
class template used by the default implementation.

>>> Named quantity?
>>
>> A named quantity has a name. In practise in Quan-0_2_0 this means
>> that, where U
>> is a model of StaticUnit and is_named_quantity<U>::value is true, that
>> get_named_quantity_traits<U>::type , returns a traits class, which
>> provides
>> useful information, such as the name of the quantity and other
>> information
>> mainly useful for I/O purposes.
>
> I assume that this mean that the unit has a special name, and
> additional information?

Yes. The classic example is torque and energy. They are dimensionally
equivalent, but have different output

Energy in Joules is output as J..
Torque as N.m

Note: I am aware that the output as it stands is pretty fixed ( It is still
useful for getting some output in quick examples and tests though), but One day
hopefully it should be possible to use locales and facets or whatever and
somehow to customise for various file formats.. I hope that functionality could
be added by someone with experience of that type of thing if Quan got into boost
, or at least I could get advice on how to go about it. This is the idea anyway
of the NamedQuantityTraits Concept.

>>> Concrete quantity?
>>
>> A concrete quantity is a quantity which has a unit and a numeric
>> value.
>
> Same confusion as with abstract quantity. Isn't abstract quantity
> just the unit? I

All this has data been moved into the StaticUnit in the latest version of Quan,
yes.

>>> Anonymous quantity?
>>
>> An anonymous quantity doesnt have a name, kind of the opposite of a
>> named
>> quantity. is_named_quantity<U>::value is false for anonymous
>> quantities in the
>> next version of Quan, and so their Named Quantity Traits class is
>> effectively
>> void.
>
> 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.

 Again this seems
> to be a property of the unit of the quantity. Wouldn't unnamed unit
> be a better name?

I prefer anonymous FWIW. Someone who writes a letter anonymously does have a
name, we just don't know what it is, so that is not quite the same as someone
not having a name. Anonymous quantities do represent a particular quantity, but
because they arise from calculations, then it is not possible to know which
quantity is intended, so it is not possible to know what their name is.
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.

>>> Static unit?
>>
>> This is a proper C++ Concept. Effectively its a compile time database
>> which can be queried about various aspects of a particular
>> fixed_quantity. It is
>> a template parameter to fixed_quantity:
>>
>> fixed_quantity<StaticUnit,NumericType>
>>
>>> United value?
>>
>> It is a detail of the implementation. Has it leaked into the docs
>> somewhere? If
>> so I will remove it as it may change without notice.
>>
>>> A
>>> general-purpose library should use simple terms and a bare minimum
>>> of names.
>
> If I understand the above concepts correctly then we only need three
> terms:
>
> - named unit
> - unnamed unit
> - quantity (value + unit)

Strictly speaking AFAIK the 'value' of a quantity is the numeric value + unit.

Otherwise that is quite close to the latest thinking in the latest CVS Version
of Quan. It is (almost) summed up in the fixed_quantity definition.

fixed_quantity<StaticUnit,NumericType>

(A Static Unit is just a Unit where all the data is available at compile time.)

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