Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2004-01-09 14:36:04

Phil Richards wrote:
> Indeed (though ISO have added "bel" and something else that I can't
> remember). It should be pointed out that when the phrase "Dimensional
> Analysis" is used with respect to "quantities", it pretty much *only* ever
> means "physics-related" - I recommend a google or vivisimo search. (I
> have tried to find some other place that "dimensional analysis" is
> performed that doesn't used the normal set, but have yet to find it...
> that's just probably bad eyesight.)

That may be true, but I think many others and I have tried to point
out that the underlying principles of "Dimensional Analysis" are
quite useful for dimensions and quantities that have nothing to do
with physics.

> No, what you have described is a library that requires dimensional
> analysis support: to deal with (sqrt(joule) / root<3>(joule))-type
> calculations you need to keep track of dimensions the base dimensions.
> (time and energy).
> There is definitely something that could be described as a "unit library",
> but things defined in it would have trouble interacting with each other:
> without dimensional analysis, you can't have multiplicative operations
> (apart from with the underlying value_type).
> Example:
> joule<double> j(1);
> second<double> s(1);
> // what is typeof(j / s) ?
> Without "dimensional analysis"-like functionality, you are stymied - you
> aren't going to get something of type "watt", or even something that is
> convertible to it.

For me this is the guts of the units library. Namely, it should
automatically define derived units that arise when doing arithmetic
operations involving quanitities given in units. If your physical
quantity library is doing this for predefined physical units, I don't
understand why
it wouldn't be a smaller library if it simply did it for user-defined
units and skipped the step of pre-defining the units.

To answer your question "what is typeof(j / s)", you would do
what Hugo Duncan described a long, long time ago. A unit type
would consist of a typelist of fundamental unit tags (all user-defined,
if I had it my way) and a rational number associated with each
tag. Then the type of "j/s" would be a typelist
containing a tag representing joules (with an exponent of 1) and
another tag representing seconds (with an exponent of -1).

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