From: Janek Kozicki (janek_listy_at_[hidden])
Date: 2006-06-17 19:33:41
Andy Little said: (by the date of Wed, 14 Jun 2006 21:27:34 +0100)
> > With this mechanism maybe the amount of predefined units can be reduced
> > - maybe even only to one unit per dimension and no mixed units at all?
> I think there is a case for providing what I would call different 'views'. I
> have concentrated on one 'view' in which the units are explicitly spelt out.
> that is the one dealing with named-quantities, typedefs for particular units (
> pqs::length::m) , etc, etc. This is helpful when unit conversions are needed.
Yes, those particular typedefs (when unit conversions are needed) could
be included from separate file.
> However, (though I havent looked in real detail at yade yet)
> from the current brief look I have had so far it occurs that for this type of
> use a different view, created by just typedefing quantities for their names
> (length, time, force etc) in implied base units, would be more suitable.
> ( In yade I think the unit conversion capability is irrelevant ?).
Actually I was thinking about using conversions, but only for
serialization purposes. So yade internally uses the base SI units, but
during input/output the user can pick the desired units from dropdown
menu. But (very important) this process is handled ONLY by serialization
module and converts the input to the base SI unit. So that whole rest of
yade doesn't have to care about that and safely assume that all the
calculations are in base SI unit - as it is currently now.
I will reitarate - unit scaling (MN vs. kN vs. N) belongs to serialization.
> This type of use
> would also facilitate being able to switch PQS library in for dimensional
> analysis checking and then switch the library back to floating point types for
> max performance of the release version.
yes, good point.
> In this case use of other than base units wouldnt be suitable,
Yes, but remember that it's the library user who choses the base units
in his calculations. I can pick base SI units, but physicists will pick
electronovolt as a base unit, and speed of light = 1.
> though even here unit conversions could be achieved
> ( maybe via the alternate syntax favoured by Walter Browns SI Units and Jesper
> Schmidt), if necessary.
Yes, I prefer this syntax (as a reminder):
Jesper Schmidt wrote:
> In generel I have a hard time understanding the motivation for
> introducing unit-types instead of just quantity types. Personally I
> length x = 10 * meter();
> length::m_div_s x(10)
> because the former is closer to the syntax from the real SI system.
And with this macro from parent post, and other macros suppyling this
one, and perhaps with boost typeof, this Jesper's machanism can be quite
easy to acheive.
-- Janek Kozicki |