formal review request : mcs::units

I hope I'm not running the risk of inducing Boost Unit burnout by making this request shortly after the review of Andy Little's proposal to add dimensional analysis and units to Boost...I'm hoping that the interest level will stay high enough to pull through one more review. Since the input from the recent informal review seems to have petered out, and I believe I've addressed the majority of the issues raised, this seems like an appropriate time to request a formal review of mcs::units. An issue that does concern me is feature creep - in the past, there seems to have been an ever-growing cycle of increasingly complex feature requests/needs/ desires. To try to focus the review, here is a summary of the intended scope of the library: mcs::units is a library providing zero-runtime overhead dimensional analysis for unit and quantity calculations. It provides support for 1) unit systems comprised of arbitrary sets of base units 2) arbitrary user-defined value types 3) support for heterogenous operator algebras (i.e. Z op(X,Y)) 4) support for basic outputting of quantities 5) optional support for implicit unit conversions It does not support 1) runtime units or quantities 2) input or parsing of quantities The most recent version (mcs_units_v0.5.7.zip) is in the Boost Vault (http://www.boost-consulting.org/vault/), in the Units directory. As always, comments/suggestions/requests are welcome. Cheers, Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

AMDG Matthias Schabel <boost <at> schabel-family.org> writes:
The most recent version (mcs_units_v0.5.7.zip) is in the Boost Vault (http://www.boost-consulting.org/vault/), in the Units directory. As always, comments/suggestions/requests are welcome.
Just one thing. How about using Boost.Typeof? In Christ, Steven Watanabe

Just one thing. How about using Boost.Typeof?
I tried using Boost.Typeof in a much earlier incarnation, at which time it didn't work. Assuming the library gets incorporated into Boost, that would be a logical thing to add. For now I'd rather not mess too much with the internals since they're working satisfactorily and changing over to Boost.Typeof would just be an implementation detail anyway.... Will put it on the to-do list, though. Thanks, Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

AMDG Matthias Schabel <boost <at> schabel-family.org> writes:
Just one thing. How about using Boost.Typeof?
I tried using Boost.Typeof in a much earlier incarnation, at which time it didn't work. Assuming the library gets incorporated into Boost, that would be a logical thing to add. For now I'd rather not mess too much with the internals since they're working satisfactorily and changing over to Boost.Typeof would just be an implementation detail anyway.... Will put it on the to-do list, though.
You might want to switch on BOOST_TYPEOF_NATIVE. That will at least catch compilers that use __typeof__ + msvc while avoiding the possibly expensive registration/lookup mechanism. In Christ, Steven Watanabe

systems/si/base.hpp defines specializations of unit_info. there is not declaration of unit_info in any of the files that it directly of indirectly includes.
Michael noticed this too - I've fixed it for the next update.
You might want to switch on BOOST_TYPEOF_NATIVE. That will at least catch compilers that use __typeof__ + msvc while avoiding the possibly expensive registration/lookup mechanism.
I'm not familiar enough with Boost.Typeof to know what that does - is it just a #define somewhere before typeof is called, then replace typeof with BOOST_TYPEOF? Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

AMDG Matthias Schabel <boost <at> schabel-family.org> writes:
I'm not familiar enough with Boost.Typeof to know what that does - is it just a #define somewhere before typeof is called, then replace typeof with BOOST_TYPEOF?
I meant #ifdef BOOST_TYPEOF_NATIVE //BOOST_TYPEOF implementation #else //other implementation #endif In Christ, Steven Watanabe

AMDG Matthias Schabel <boost <at> schabel-family.org> writes:
The most recent version (mcs_units_v0.5.7.zip) is in the Boost Vault (http://www.boost-consulting.org/vault/), in the Units directory. As always, comments/suggestions/requests are welcome.
cmath.hpp adds overloads to namespace std. You can't do that. (17.4.3.1/1) In Christ, Steven Watanabe

cmath.hpp adds overloads to namespace std. You can't do that. (17.4.3.1/1)
Well, you can, but it makes you a very, very bad person ;^) I've moved them into boost::units for the next update. Thanks for catching that. Matthias ---------------------------------------------------------------- Matthias Schabel 2859 Glen Oaks Drive Salt Lake City, UT 84109 801-706-5760 (cell) 801-484-0811 (home) matthias at stanfordalumni dot org ----------------------------------------------------------------  ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

AMDG systems/si/base.hpp defines specializations of unit_info. there is not declaration of unit_info in any of the files that it directly of indirectly includes. In Christ, Steven Watanabe

AMDG I would suggest that you have a pod_quantity for defining the various constants so that they can be safely used during the dynamic initilization phase. In Christ, Steven Watanabe

I would suggest that you have a pod_quantity for defining the various constants so that they can be safely used during the dynamic initilization phase.
I'm not sure I follow you here...could you elucidate a little more? At this point, I'm not sure whether the constants are appropriate for inclusion in the library or as an example - what I would prefer to do is to encapsulate them in something like the measurement class so that the errors are also accessible, but I'm worried that trying to include such a class would start to get out of the scope of the core library itself. In particular, I think that a measurement-like class that does standard propagation of errors would also be critical for any Boost numerical methods library (GSL provides a result type that encapsulates value/error pairs) and could share an implementation... Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

AMDG Matthias Schabel <boost <at> schabel-family.org> writes:
I would suggest that you have a pod_quantity for defining the various constants so that they can be safely used during the dynamic initilization phase.
I'm not sure I follow you here...could you elucidate a little more?
template<class Unit, class T = double> struct pod_quantity { //like quantity but without constructors/assignment operators T val_; }; constants.hpp pod_quantity<si::velocity> c = { 299792458 }; (for example) In Christ, Steven Watanabe

Hi Boost moderators, Is there any policy with regard to non-technical content on the boost list? The last few times I've checked the list I have been presented with material like that included at the end of this message. While this particular material does not relate to me, some policy would be good. Is promotion of the different religions, ethnic groups, sexual orientations and political leanings acceptable on the boost-list? Regards, Scott To: <boost@lists.boost.org> Sent: Wednesday, February 07, 2007 12:46 PM Subject: Re: [boost] formal review request : mcs::units
AMDG

I am not a Boost moderator but I have strong feelings about this. Is it in the name of political correctness that you send such a message? People are humans, humans have beliefs. Simple as that. I don't see why something as inconsequential as an acronym should offend anyone or have anyone be asked to stop using it. There is blatant outright annoying and simple. I'm sure you'll hear more people b*tching if there is an outright annoying email (don't reply to mine saying this is outright annoying!) Annoying: <Something> is (good|bad|smart|stupid) because they do <X> Not annoying: AMDG Bottom line: Don't make an issue where there is none PS: If you want to see annoying non-technical content in technical postings, there are plenty of examples (http://tinyurl.com/2gz9rw) always comes to mind -----Original Message----- From: boost-bounces@lists.boost.org on behalf of Scott Woods Sent: Tue 2/6/2007 8:12 PM To: boost@lists.boost.org Subject: [boost] Non-technical content Hi Boost moderators, Is there any policy with regard to non-technical content on the boost list? The last few times I've checked the list I have been presented with material like that included at the end of this message. While this particular material does not relate to me, some policy would be good. Is promotion of the different religions, ethnic groups, sexual orientations and political leanings acceptable on the boost-list? Regards, Scott To: <boost@lists.boost.org> Sent: Wednesday, February 07, 2007 12:46 PM Subject: Re: [boost] formal review request : mcs::units
AMDG
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

As a vehemently secular leftie-pinko intellectual, I don't find this to be particularly offensive. For postings that are primarily technical, let's not get our undies in a bunch, live and let live, blah, blah, blah... Anyway, why would a pitch for the Association of Deer Management Groups be offensive to anyone? Matthias
Hi Boost moderators,
Is there any policy with regard to non-technical content on the boost list?
The last few times I've checked the list I have been presented with material like that included at the end of this message.
While this particular material does not relate to me, some policy would be good. Is promotion of the different religions, ethnic groups, sexual orientations and political leanings acceptable on the boost-list?
Regards, Scott
To: <boost@lists.boost.org> Sent: Wednesday, February 07, 2007 12:46 PM Subject: Re: [boost] formal review request : mcs::units

Matthias Schabel wrote:
As a vehemently secular leftie-pinko intellectual, I don't find this to be particularly offensive. For postings that are primarily technical, let's not get our undies in a bunch, live and let live, blah, blah, blah... Anyway, why would a pitch for the Association of Deer Management Groups be offensive to anyone?
LOL :-) Well, I had to look up what the acronym means, and to be honest this moderator almost never reads signature lines anyway, so it's mostly a "shrug" I guess. Generally speaking we try to let things pass unless they have an effect on the smooth running of the group: I don't think we're at that point yet, but please do speek up (either in public or too the moderators privately) if you think otherwise, or if a particular signature crops up that you find offensive. John Maddock.

----- Original Message ----- From: "John Maddock" <john@johnmaddock.co.uk> To: <boost@lists.boost.org> Sent: Wednesday, February 07, 2007 10:58 PM Subject: Re: [boost] Non-technical content
Matthias Schabel wrote:
As a vehemently secular leftie-pinko intellectual, I don't find this to be particularly offensive.
Me either.
For postings that are primarily technical, let's not get our undies in a bunch, live and let live,
You really dont want to bring my undies into this.
blah, blah, blah... Anyway, why would a pitch for the Association of Deer Management Groups be offensive to anyone?
Dont know. If I had a concern it was that I couldn't remember any discussion in this area (e.g. religious, ethnic or political content). Communication is usually a good thing and early is usually better than late.
LOL :-)
Well, I had to look up what the acronym means, and to be honest this moderator almost never reads signature lines anyway, so it's mostly a "shrug" I guess.
Generally speaking we try to let things pass unless they have an effect on the smooth running of the group: I don't think we're at that point yet, but please do speek up (either in public or too the moderators privately) if you think otherwise, or if a particular signature crops up that you find offensive.
Thanks John. Or as we say in our corner of the world - no worries.

--- Scott Woods wrote:
Hi Boost moderators,
I am not a moderator, but I would like to give my input on this matter.
Is there any policy with regard to non-technical content on the boost list?
Only if the substantial part of the message itself is OT (not Boost-related, appropriate for another library author, etc.) should it be [re]posted elsewhere or with another subject heading.
The last few times I've checked the list I have been presented with material like that included at the end of this message.
I consider greetings and signatures to be distinct and separate from the substantial part of a message.
While this particular material does not relate to me, some policy would be good.
I trust that each poster's common sense would prevent him or her from letting his or her greetings or signatures take the focus away from the actual content of the message, e.g. by being defamatory or libelous.
Is promotion of the different religions, ethnic groups, sexual orientations and political leanings acceptable on the boost-list?
No, but I also don't regard short, consistent, "moderate" greetings or signatures as "promotion" of anything. Rather, I appreciate these forms of expression as affirmation that I'm communicating with fellow human beings as opposed to artificially intelligent agents trying to pass the Turing Test. tc&Gb, Cromwell D. Enage ____________________________________________________________________________________ TV dinner still cooling? Check out "Tonight's Picks" on Yahoo! TV. http://tv.yahoo.com/

and I thought AMDG stood for All My Dear Geeks ----- Original Message ----- From: "Cromwell Enage" <sponage@yahoo.com> To: <boost@lists.boost.org> Sent: Wednesday, February 07, 2007 4:51 PM Subject: Re: [boost] Non-technical content << clipped>>
____________________________________________________________________________________ TV dinner still cooling? Check out "Tonight's Picks" on Yahoo! TV. http://tv.yahoo.com/ _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Send instant messages to your online friends http://au.messenger.yahoo.com

ISWT
I would suggest that you have a pod_quantity for defining the various constants so that they can be safely used during the dynamic initilization phase.
template<class Unit, class T = double> struct pod_quantity { //like quantity but without constructors/assignment operators T val_; };
constants.hpp
pod_quantity<si::velocity> c = { 299792458 };
cgs:: the code would suddenly have a bug because there would be no way for the compiler to know
The problem with this is that you lose the type-safety of forcing explicit value+unit construction of quantities. That is, if someone decided to express the constant in cgs units instead and just did a global search and replace for si:: - that the specified constant value was meant to be in SI units. By requiring constructs like quantity<si::velocity> c(299792458*si::meters/si::second); you would get an error here: quantity<cgs::velocity> c(299792458*cgs::meters/cgs::second); because there is no meter defined in cgs. There has to be a better solution to the dynamic initialization problem...anyone? Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Matthias Schabel Sent: 06 February 2007 23:25 To: boost@lists.boost.org Subject: Re: [boost] formal review request : mcs::units
I would suggest that you have a pod_quantity for defining the various constants so that they can be safely used during the dynamic initilization phase.
I'm not sure I follow you here...could you elucidate a little more? At this point, I'm not sure whether the constants are appropriate for inclusion in the library or as an example - what I would prefer to do is to encapsulate them in something like the measurement class so that the errors are also accessible, but I'm worried that trying to include such a class would start to get out of the scope of the core library itself. In particular, I think that a measurement-like class that does standard propagation of errors would also be critical for any Boost numerical methods library (GSL provides a result type that encapsulates value/error pairs) and could share an implementation...
I agree that feature-creep is looming and that Matthias is right to resist. However, it will be comforting to show that there one can sketch out prototypes to show 'proof of concept'. Failure to template can cause frustration later when this blocks extension. It can also highlight potential pitfalls. Steven's suggestion of a pod_quantity is an example. template<class Unit, class T = double> struct pod_quantity { //like quantity but without constructors/assignment operators T val_; }; pod_quantity<si::velocity> c = { 299792458 }; at first sight appears to work OK with T a value + uncertainty type - but of course one cannot then rely on its initialisation because it's not longer pod and needs a constructor. However this is really a language problem - one that is recognized and really should be solved in C++0X. So let's get walking before we try to run. Paul PS Please can we use the word 'uncertainty' rather than the obselete 'error'. Errors can be corrected, but uncertainty only reduced ;-) --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

ISWT Hi Paul,
I agree that feature-creep is looming and that Matthias is right to resist.
Thanks for sticking up for me...
However, it will be comforting to show that there one can sketch out prototypes to show 'proof of concept'. Failure to template can cause frustration later when this blocks extension.
I absolutely agree - if this library can't handle reasonable use cases or special needs relatively gracefully, then it has definitely failed it's design objective. The only way to find that out is to have people try using it, as you like to put it, "in anger" and see what shakes out... I've tried my best to put forth at least sketch solutions addressing most reasonable requests that I've seen posted here in the example code, but there will surely be more ideas that I haven't considered...
PS Please can we use the word 'uncertainty' rather than the obselete 'error'. Errors can be corrected, but uncertainty only reduced ;-)
Right. Error is officially stricken from my vocabulary in this context. In fact, I've just finished a paper that will have to be grepped ;^) Matthias ---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

Hi Matthias, I've received your request and will add your library to the review queue. Cheers, ron On Feb 6, 2007, at 4:56 PM, Matthias Schabel wrote:
I hope I'm not running the risk of inducing Boost Unit burnout by making this request shortly after the review of Andy Little's proposal to add dimensional analysis and units to Boost...I'm hoping that the interest level will stay high enough to pull through one more review. Since the input from the recent informal review seems to have petered out, and I believe I've addressed the majority of the issues raised, this seems like an appropriate time to request a formal review of mcs::units. An issue that does concern me is feature creep - in the past, there seems to have been an ever-growing cycle of increasingly complex feature requests/needs/ desires. To try to focus the review, here is a summary of the intended scope of the library:
mcs::units is a library providing zero-runtime overhead dimensional analysis for unit and quantity calculations. It provides support for
1) unit systems comprised of arbitrary sets of base units 2) arbitrary user-defined value types 3) support for heterogenous operator algebras (i.e. Z op(X,Y)) 4) support for basic outputting of quantities 5) optional support for implicit unit conversions
It does not support
1) runtime units or quantities 2) input or parsing of quantities
The most recent version (mcs_units_v0.5.7.zip) is in the Boost Vault (http://www.boost-consulting.org/vault/), in the Units directory. As always, comments/suggestions/requests are welcome.
Cheers,
Matthias
---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/ listinfo.cgi/boost

Thanks, Ron
Hi Matthias,
I've received your request and will add your library to the review queue.
Cheers, ron
---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------

It looks good and is something I would use. I haven't had a chance to try it out, though. As I've mentioned, this would be especially useful with the ability to combine accumulators. The usage I'm dreaming of is this: accumulator_set<double, stats<tag::mean, tag::moment<2> > > acc; acc = for_each(foo.begin(), foo.end(), acc); mpi::all_reduce(world, acc); // Now acc has seen all elements of foo on all MPI nodes. I'm eager to see it in action. —Ben On 2/6/07, Matthias Schabel <boost@schabel-family.org> wrote:
I hope I'm not running the risk of inducing Boost Unit burnout by making this request shortly after the review of Andy Little's proposal to add dimensional analysis and units to Boost...I'm hoping that the interest level will stay high enough to pull through one more review. Since the input from the recent informal review seems to have petered out, and I believe I've addressed the majority of the issues raised, this seems like an appropriate time to request a formal review of mcs::units. An issue that does concern me is feature creep - in the past, there seems to have been an ever-growing cycle of increasingly complex feature requests/needs/ desires. To try to focus the review, here is a summary of the intended scope of the library:
mcs::units is a library providing zero-runtime overhead dimensional analysis for unit and quantity calculations. It provides support for
1) unit systems comprised of arbitrary sets of base units 2) arbitrary user-defined value types 3) support for heterogenous operator algebras (i.e. Z op(X,Y)) 4) support for basic outputting of quantities 5) optional support for implicit unit conversions
It does not support
1) runtime units or quantities 2) input or parsing of quantities
The most recent version (mcs_units_v0.5.7.zip) is in the Boost Vault (http://www.boost-consulting.org/vault/), in the Units directory. As always, comments/suggestions/requests are welcome.
Cheers,
Matthias
---------------------------------------------------------------- Matthias Schabel, Ph.D. Assistant Professor, Department of Radiology Utah Center for Advanced Imaging Research 729 Arapeen Drive Salt Lake City, UT 84108 801-587-9413 (work) 801-585-3592 (fax) 801-706-5760 (cell) 801-484-0811 (home) matthias dot schabel at hsc dot utah dot edu ----------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

The Wikipedia page for P^2 algorithm (which I started) is very sparse. I couldn't find much information at all about it online. If you have details about it, consider adding to the wiki page: http://en.wikipedia.org/wiki/P%5E2_algorithm Cheers. —Ben

AMDG Your include guards should probably be prefixed by BOOST_UNITS_ not just BOOST_ In Christ, Steven Watanabe

Hi Matthias, I've been following the discussion about physical quantities for some times now and I'm wondering if someone has thought of representing base units by prime numbers? Any positive natural number can unambiguously be split into it's prime factors, so any rational number would be an unambiguous representation of a derived dimension with the exponents of the prime factors representing the exponents of the base dimensions. The only problem are common factors in nominator and denominator, which could be normalized using the Euclidean algorithm. Multiplying dimensions is then reduced to multiplying rational numbers with subsequent normalization. That should be a lot easier then dealing with sorted lists. I might find some time to write up an example implementation. Interested? Best wishes, Andreas

On 2/9/07, Andreas Harnack <ah.boost.01@justmail.de> wrote:
Hi Matthias,
I've been following the discussion about physical quantities for some times now and I'm wondering if someone has thought of representing base units by prime numbers?
How would you store the products? I don't really like the idea of unintuitive limits on the composition of base units (e.g. you can represent 2^31, but not 19^31) -- on the other handworking with arbitrarily-sized compile-time integers doesn't sound a lot less complicated than dealing with sorted lists, so maybe you have something different in mind? Regards, Michael

Michael Walter wrote:
How would you store the products? I don't really like the idea of unintuitive limits on the composition of base units (e.g. you can represent 2^31, but not 19^31)
I might have been a bit imprecise here, so please consider: const unsigned int Time = 2; const unsigned int Length = 3; const unsigned int Mass = 5; const unsigned int Current = 7; const unsigned int Temp = 11; const unsigned int Amount = 13; const unsigned int Intensity = 17; template <unsigned int N, unsigned int D=1> struct Rational { ... }; typedef Rational<Time> time; typedef Rational<Length> length; typedef Rational<Mass*Length,Times*Times> force; typedef Rational<Mass*Length*Length,Times*Times> energy; quantity<energy, double> e; so the representation of energy would be just 5*3*3/2*2 = 45/4. You're right, there is a computational limit, but I wouldn't expect to a see a dimension with the power of 31. Exponends of 4 are about the highest I've ever seen, and (2*3*5*7*11*13*17)^3 still fits in 57 bits, so we might want to use long or even long long unsigned ints, but that should be fine for most situations. Andreas

----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Andreas Harnack Sent: 09 February 2007 14:11 To: boost@lists.boost.org Subject: Re: [boost] formal review request : mcs::units
Michael Walter wrote:
How would you store the products? I don't really like the idea of unintuitive limits on the composition of base units (e.g. you can represent 2^31, but not 19^31)
I might have been a bit imprecise here, so please consider:
const unsigned int Time = 2; const unsigned int Length = 3; const unsigned int Mass = 5; const unsigned int Current = 7; const unsigned int Temp = 11; const unsigned int Amount = 13; const unsigned int Intensity = 17;
template <unsigned int N, unsigned int D=1> struct Rational { ... };
typedef Rational<Time> time; typedef Rational<Length> length; typedef Rational<Mass*Length,Times*Times> force; typedef Rational<Mass*Length*Length,Times*Times> energy;
quantity<energy, double> e;
so the representation of energy would be just 5*3*3/2*2 = 45/4.
You're right, there is a computational limit, but I wouldn't expect to a see a dimension with the power of 31. Exponends of 4 are about the highest I've ever seen, and (2*3*5*7*11*13*17)^3 still fits in 57 bits, so we might want to use long or even long long unsigned ints, but that should be fine for most situations.
How would you deal with fractional powers of units? (The subject came up in the pqs/quan review, and it was clear they were significant to some people). -- Martin Bonner Project Leader PI SHURLOK LTD Telephone: +44 1223 441434 / 203894 (direct) Fax: +44 1223 203999 Email: martin.bonner@pi-shurlok.com www.pi-shurlok.com

Martin Bonner wrote:
How would you deal with fractional powers of units? (The subject came up in the pqs/quan review, and it was clear they were significant to some people).
Yes, I've seen such comments too, but I couldn't find a posting explaining in which context it's needed. Do you have a reference by any chance? Andreas

The notion of "volatility" of a stochastic process is used throughout finance for measuring the value of an option and has units equal to time raised to the -1/2 power. It has an analogue in physics that might be called a heat conduction coefficient or diffusion coefficient (apologies to physicists for making up my own terminology), because it corresponds to the coefficient c in the heat equation u_t = c^2 u_xx I currently use my own homegrown units template library and implemented +/-(1/2) powers. Deane Andreas Harnack wrote:
Martin Bonner wrote:
How would you deal with fractional powers of units? (The subject came up in the pqs/quan review, and it was clear they were significant to some people).
Yes, I've seen such comments too, but I couldn't find a posting explaining in which context it's needed. Do you have a reference by any chance?
Andreas
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

I currently use my own homegrown units template library and implemented +/-(1/2) powers.
Deane
Hi Deane, Just out of curiosity, what drove you to implement your own? Have you had a chance to try the latest versions of mcs::units? Since I'm proposing it as an official Boost library, I'd like to get as much input from prospective users at the front end as possible so, if there are reasonable use cases that it doesn't accommodate reasonably easily now, changes can be made. Matthias

Matthias Schabel wrote:
I currently use my own homegrown units template library and implemented +/-(1/2) powers.
Deane
Hi Deane,
Just out of curiosity, what drove you to implement your own? Have you had a chance to try the latest versions of mcs::units? Since I'm proposing it as an official Boost library, I'd like to get as much input from prospective users at the front end as possible so, if there are reasonable use cases that it doesn't accommodate reasonably easily now, changes can be made.
I implemented mine years and years ago. Both linear and affine units. At the time, there were no template template parameters, and this made things awkward because I don't always want an underlying double (I often need a UDT) representing the number. I've been very interested in these libraries, but so far they are all too physics-centric for my taste. Also, I've been totally overwhelmed, so I haven't had the time to look at your library at all. I think I took a look at an earlier version and commented favorably on it, though. If I ever find the time, I'll take a look and comment. If you dig through the boost archives, you'll find lots of comments by me about what I'm looking for.

Deane,
I've been very interested in these libraries, but so far they are all too physics-centric for my taste. Also, I've been totally overwhelmed, so I haven't had the time to look at your library at all.
I think I took a look at an earlier version and commented favorably on it, though.
You did - in fact, it was you that encouraged me to push implementation of heterogeneous operators in this library. I understand the overwhelmed phenomenon - this code sat for three years in stasis before being exhumed... Despite being a physicist myself, I've tried fairly hard to make this library as general as possible without compromising performance or ease of use. I guess time will tell if I've succeeded...
If I ever find the time, I'll take a look and comment. If you dig through the boost archives, you'll find lots of comments by me about what I'm looking for.
I do hope you manage to scrape together the time to play with it a bit. I know how valuable time is, which makes the whole Boost/open source enterprise and its successes all the more surprising to me. You were quite active in earlier unit/dimensional analysis discussions, and some of your suggestions certainly helped to shape the interface. At this point, it should be fairly mature and mostly self-explanatory. I'd love to hear what you think. Regards, Matthias

Deane Yang said: (by the date of Fri, 09 Feb 2007 17:33:51 -0500)
I currently use my own homegrown units template library and implemented +/-(1/2) powers.
From previous discussions I remember that the half powers were useful in some statistics stuff. You had units, calculated standard deviation, or something like that, and you ended up with a power of 1/2. I'm 100% sure there was a discussion about that in PQS threads. -- Janek Kozicki |

On 2/9/07, Andreas Harnack <ah.boost.02@justmail.de> wrote:
You're right, there is a computational limit, but I wouldn't expect to a see a dimension with the power of 31. Exponends of 4 are about the highest I've ever seen, and (2*3*5*7*11*13*17)^3 still fits in 57 bits, so we might want to use long or even long long unsigned ints, but that should be fine for most situations.
Alright, I was thinking of 32 bits which would overflow (significantly?) earlier. Still, I feel slightly uneasy about this limitation as well as the asymmetry mentioned above. I also wonder how to extend this concept to allow defining custom units and/or unit systems in a sensible way. Regards, Michael
participants (18)
-
Andreas Harnack
-
Andreas Harnack
-
Andreas Harnack
-
Ben FrantzDale
-
Cromwell Enage
-
David Abrahams
-
Deane Yang
-
Janek Kozicki
-
John Maddock
-
Martin Bonner
-
Matthias Schabel
-
Michael Walter
-
Minh Phanivong
-
Paul A Bristow
-
Ronald Garcia
-
Scott Woods
-
Sohail Somani
-
Steven Watanabe