[Home]DimensionsAndUnits

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Difference (from prior major revision) (minor diff, author diff)
No diff available.

What's the status of the units libary(ies)? Is anybody working on getting code ready to submit?

This is the Walter Brown's library. You can send him and email at wb@SPAMBLOCKfncrdg.fnal.gov. -- People/Jeff Garland 2001-Sep-29


Does someone know the necessary tricks to get SIunits to compile with gcc 2.95?

From my understanding SIUnits has gone through a complete rewrite. I don't know if it has been tested with gcc. Anyway, ask Walter -- People/Jeff Garland 2001-Sep-29

Ok, thanks. I don't have immediate need of it. I'll just wait for the reworked version. Thanks. -- Eford 2001-Sep-30


Here's a library by Kasper Peeters that looks interesting also: http://www.damtp.cam.ac.uk/user/kp229/dimnum/

-- People/Fredrik Blomqvist 2002-Oct-30

---

I decided that I needed a workable units library, so I wrote one. It allows for weakly typed dimensioned quantities (so a length divided by a time is automatically converted to a velocity). It also allows users to use strong typeing for quantities of the same dimension which shouldn't be confused (so you don't set a mass of apples equal to a mass of oranges).

I attempted to make it pretty general, allowing for all the standard SI dimensions, a dimension for money (since that is something lots of people care about), and I've left one dimension avaliable for users. Fractional powers of dimnensions are allowed. (It also includes a compile-time fractions header file that might be useful for other purposes.) Power users could setup units using their own classes for the internal numeric type or even provide their own systems of units.

I uploaded the first draft version of it to the vault a ebf_units.zip. I've included several demonstration programs to show how it can be used.

example1.cpp demonstrates the use of simple SI units, including arithmetic on such variable and automatic conversion when multiplying or dividing dimensioned quantities.

example2.cpp demonstrates how you could use multiple representations (e.g., float and double) in the same program. I've included extremely crude numeric type promtion mainly for demonstration purposes.

example3.cpp demonstrates the use of multiple systems of units in a single program (e.g., including both standard/si/mks units and "relativistic units where the speed of light is set to unity). SIUnits only allows one in a program. Any conversions between systems must be made explicitly.

example4.cpp demonstrates basic use of "qualifiers". These allow users to make strongly typed units, so that quantities of the same dimension, but different meaning can't be confused. (e.g., a mass of apples and a mass of oranges)

example5.cpp demonstrates how a user can extend this to allow for some automatic conversions (e.g., automatically convert apples to fruits, but not vice versa, or add apples and oranges and assign the result to fruits).

Known bugs/limitations:

- - In the mks_double and mks_single namespaces, time is non-standard in that it is capitalized unlike all the other dimenions. This is due to my compiler (g++ 3.0.4 on rh) having conflicts with time (which I beleive should be in the std namespace). Help on solving this would be appreciated.

- - Many more dimensions could be predefined in the standard system (basically SI). However, I'd prefer not to define every possible unit (like SIunits), particularlly those that are not frequently used (e.g., furlong) and/or those which can be easily constructed by the user (e.g., meters per second).

- - Headers for other internal numeric representations (e.g., mks_int ???) could be included.

- - Other systems (quantum, natural, planetary, ...) could be included.

- - The system tag classes (e.g., mks_tag, which provides for identifying which system of units is being used and labeling the dimension of quantities) could be made more intelligent. For example, SIUnits allows users to set the default unit that they'd like a quantity with a certain dimension to be displayed as. Since one can simply divide by whatever unit they want their result in, I don't see much point. However, if someone wanted this, they should be able to add such features by replacing the sytem tag class class without touching the rest.

Bugfixes, improvements, encouragment, and other feedback would be welcome.

-- eford 2003-Feb-28


BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited November 5, 2004 5:02 am (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers