Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2004-01-07 17:04:40

> In particular, I do not like defining dimensions such as length as
> types
> and units such as meters as constants, because it begs the question of
> how a dimension such as length should be represented internally (you
> end up choosing an internal unit to use). This

You need to be careful to make the distinction between a unit which is
a member of the "basis" for a unit system (for example, the units which
are bases of the SI system are meters, Kelvin, Kilograms, seconds,
etc...) and a quantity which is a scalar value in a particular unit
system. The abstraction that I've been using works like this :

SI<double>::length len(2.0*_meters);

where SI<double> specifies the basis of the unit system and the
precision of the representation of quantities and _meters is a
"constant" which carries only type information (there is no contained
value since it is implicitly one) and is defined to enable the use of
the * operator to form a quantity (value in a unit system) from a
scalar and a unit. The point of this is that, in the SI system the
meter is a member of the basis and the foot is a quantity which can be
expressed in meters while in the English unit system, the foot is the
basis and the meter the derived quantity.

> And, wouldn't this units library be much simpler to develop than the
> whole physical dimensions library? I think that Abrahams, Duncan, and
> Schabel have already pretty much described how to do it. The only
> difficulty I am aware of is the compilation time involved in handling
> lists of types that represent the different fundamental units in
> a derived unit.

The dimensional analysis code already exists and works : see
test_dimensional_analysis.cpp and included headers from YANL to see the
abstract system work, including defining dimension tags, etc...

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)
mschabel at ucair med utah edu

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