Boost logo

Boost :

From: David Richardson (dgr24_at_[hidden])
Date: 2003-10-16 08:08:36


Paul A. Bristow wrote:
> |
> | The slides have examples where the units are from physics. So you
> | represent a number's units as a n-tuple of exponents with each
> | exponent corresponding to one of the fundamental SI units.
> | Arithmetic operations on numbers with these units have well
> | defined rules to compute the resulting units.
> |
> | If the semantics of the exponents in the n-tuple are user defined, ...
> <snipped>
>
> Would an example here be if the exponents in the n-tuple were of type rational
> rather than type integer?
> Could this meet the need for fractional dimensions?
> (At the cost of making it even more complicated! Especially to ensure it doesn't
> have a run-time cost).

The library has to make some choice about the internal way it
represents the exponents, and the users just have to follow
whatever convention the library has.

The concern is if a user stuffs dimensions into the n-tuple that
do not have the same semantics the library expects (e.g.
multiplication of two numbers does not result in the exponents in
their n-tuples being added). If the library is hard coded to do
conversion as if the n-tuple contained physical dimensions, the
library may incorrectly compute types for arithmetic expressions.

But allowing the user to specify both the contents of the n-tuple
and the conversion rule seems to make implementation harder, and
it isn't clear (at least to me) how many problem domains/users
would benefit from this flexibility.

Dave


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