Boost logo

Boost :

From: Topher Cooper (topher_at_[hidden])
Date: 2006-06-12 17:23:15


At 11:10 AM 6/12/2006, you wrote:
>the same units. Since the coordinate system is another thing that should
>be problem dependent, even simple vectors like the position of a
>particle may have mixed units.
>
> John Phillips

(and other comments on vectors, matrices, tensors etc.).

I have no idea how practical this would be but I think a different
take on this might resolve these problems, at least in principal.

I would say that it is a mistake to view the elements of a vector
(matrix, whatever -- for simplicity, I'll just refer to matrices
henceforth) as having "units" per se.

Rather a matrix is itself a quantity, just as a scalar is, but one
with, for lack of a better term, structure. Just as a scalar can
have associated units (type), so can a matrix. The "unit" in this
case is structured in the same way as the quantity. One consequence,
perhaps the most direct, for this "structure" in the quantity, is
that there are accessor functions on that matrix that return scalar
quantities with scalar units. To multiply two matrices they must be
compatible, not only in shape but in other aspects of their
structure. Given that the units (complete structure) of the two
matrices are compatible, they can be multiplied together and the
"unit" for the result is well defined. Once compatibility has been
checked the unitless "values" for the quantities (e.g., old-fashioned
matrices of floats) are numerically multiplied and the result is cast
to the proper structured unit.

This is just a matter of separating the abstract interface from the
particular implementation. It is a conceptual error to automatically
equate a position in 3-space as being interchangeable with an array
of floats or doubles with one dimension and three elements
representing orthogonal distances from an origin. The latter is how
the concept might (or might not) be implemented.

Topher Cooper


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