Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2003-10-24 22:42:41

There seems to be significant interest in a library which deals with
units with no runtime cost, given the email traffic over the past few
weeks. I've been
following the thread with interest as I had already implemented a units
library of my
own. My library addresses a number of the desired features which have
arisen in
this discussion :

        1) decouples the dimension code from the physical units, abstracting
                dimension, dimensioned unit (meter, erg, etc...), and dimensioned
                (1.6 meters, etc...) types
        2) provides for multiple unit systems
        3) calculations within a single unit system are performed using native
        4) conversions between units use a base unit system (e.g. SI for
physical units) which is specified
                by the implementer of the unit models
        5) rational powers are fully supported
        6) straightforward construction of new composite unit types
        7) dimensionless quantities implicitly converted to value_type
        8) provides typedefs for commonly used units
        9) provides for rational powers and roots
        10) provides appropriate arithmetic operations
        11) user specified value type can be any type which implements basic
arithmetic properties
        12) zero runtime cost except for unit conversions
        13) invalid expressions detected at compile time
        14) formatted I/O

not addressed are :

        1) arbitrary lists of dimension types (I'd be happy to work with an
MPL guru to pull this off, but
                don't have the time or expertise to do it myself at the moment).
        2) affine units (Centigrade/Fahrenheit type units which have an offset
in addition to a scale factor).
        3) uncertainty/error propagation. I think this would most profitably
be addressed by a class which
                separates out the error propagation functionality. This could almost
certainly be used as the
                value_type in a dimensioned quantity.
        4) comparison operators - these are in the works and are relatively
trivial to implement
        5) tagged units - could also be implemented as separate class and used
as a value_type
        6) logarithmic/nonlinear units - seems to far afield, given that this
would require supporting any
                arbitrary nonlinear unit type

The library is in the usual place, including a test routine :,
and works with both GCC 3.1 and CodeWarrior 8.3 (mostly) under Mac OS X.

It would be great to get something agreed upon - it seems like there is
definitely enough interest.



Matthias Schabel, Ph.D.
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)

Boost list run by bdawes at, gregod at, cpdaniel at, john at