|
Boost : |
From: Phil Richards (news_at_[hidden])
Date: 2004-01-13 13:39:43
On Mon, 12 Jan 2004 10:04:54 -0500, Deane Yang wrote:
> Seriously, I really do want to know. In fact, could everybody involved
> in this discussion who has actually used a dimensions library describe
> some of the specific applications? I have described what I use mine for
> in some detail, but I realized that I don't know what others use theirs
> for. Please don't hesitate to give the gory technical description; some
> of us are fairly comfortable with physics.
Well, I use one for real-world modelling and simulation. Unfortunately, I
can't actually say any more than that :-) It is, let's say, rather
important that equations are correct otherwise there could be unpleasant
consequences. Unit checking and dimensional analysis is just one of the
tools.
The library is used for all "real-world" (relative) quantities. It is
used all the time - we have 100's (1000's?) of times more dimensionally
analysed equations than any of the test programs for YANL or my own
combined (and it is growing all the time). This is why compile-time *is*
seriously important to me.
Our experience has shown that the majority of the time we use one "unit
system" (SI), and a very small set of value_types (double, matrix,
vector, and their ilk). Yes, we have a limited problem domain ("real
world" - as opposed to quantum, relativistic, etc), but I suspect that
once a unit system has been picked for an application, the same one will
be used (pretty much) throughout - if you don't, then conversion between
quantities based in different (dimensional) systems becomes problematic.
I tend to think that what might actually be wanted is the ability to
define a dimension system of fixed size that is used as a basis for a unit
system.
Matthias sort of has it with is physical_unit_model stuff - my
feeling is that you could lose the mpl::list approach and use an
mpl::vector instead - this is what I will try out next - one vector will
define the "allowed" dimensions, and then a unit_system will be defined
that specifies a "compatible" unit for each dimension.
Maybe something like:
struct time_d {};
struct mass_d {};
struct length_d {};
typedef dimensionality<3, time_d, mass_d, length_d> simple_physical;
typedef unit_system<simple_physical, units<second, kilogram, meter> > si;
(Yes, dimensionality is meant to look remarkably like mpl::vector.)
second must have dimensionality "time_d" - or maybe this defines second to
have dimensionality time_d.
It all becomes a mess, though, when you allow people to define a new
"raw" dimensions like:
struct speed {};
because you real want:
typedef minus<length, time>::type speed;
I dunno. Something feels almost right, but it's not there yet.
phil
-- change name before "@" to "phil" for email
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk