Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2006-09-04 01:45:19


After a multi-year hiatus, the continued discussion on the boost
mailing list regarding dimensional analysis
and units/quantities, the recent review and rejection of Andy
Little's Quan library, and a certain compulsive
masochistic need to work on tangential projects at odd intervals has
inspired me to dust
off the old code and add a significant amount of documentation
elucidating the design and implementation
of my take on the units issue. For better or worse, Andy and I have
significant differences in the way we have
approached this problem and, it seems, in our desires/requirements
for such a library. The library code that
has been uploaded to the Units folder in the vault as mcs_units.zip
is a somewhat revamped version
of what was previously known as YAnL (Yet Another units Library), now
mcs::units. In a testament to the
design and stability of MPL, essentially no changes were needed in
the metaprogramming code that deals
with dimension lists. However, compilation times seem much better,
probably because the compiler makers
have been catching on to the value of MPL and metaprogramming
techniques. In any case, I'd be delighted
to get any concrete, constructive input on design, implementation,
performance and any other relevant issues.
I'm hoping that we're converging by iteration here, and not stuck in
a limit cycle...

>>> unit<quantity<length, 1, mass, 1> >
>>> unit<quantity<mass, 1, length, 1> >
>>
>> Why do you use the word 'unit' in these examples? I don't see
>> any units in there. A unit is a standard of measure. A meter
>> is a unit. Mass and length are dimensions.
> The first template parameter describes the quantity that is
> measured and the
> second parameter controls how many of that quantity. If the second
> one is
> omitted then it is assumed that there is only one way (used) to
> measure that
> quantity.

I address this issue by representing single dimensions as a pair of a
unit tag and a static_rational
exponent. The tag type provides an ordinal value that can be used for
compile time sorting of the
full type list for composite dimensions. The code that does this is
primarily in dimension_tag.hpp and
dimension.hpp; documentation is in the usual place.

Cheers,

Matthias

----------------------------------------------------------------
Matthias Schabel, Ph.D.
Assistant Professor, Department of Radiology
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
matthias dot schabel at hsc dot utah dot edu
----------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk