Such an ability is advantageous, and in some cases in fact necessary, in various types of scientific calculations, where the value of a quantity is given in an appropriate unit. The importance of quantity calculus has been demonstrated in many contexts, ranging from correct, consistent, and unambiguous labeling of graph axes and table headings [White_1998], to the spectacular failure of a spacecraft caused by the mix-up of units [Hall_2002].
The value does change if we substitute the unit to another valid one, i.e. one which is conventionally used for this type of quantity [Cohen/Cvitas/etal_2007], in a predefined, proportional manner. Quantities enforces the consistent use of units according to the internationally acknowledged Système International d'Unités (SI). Idiosyncrasies of some particular SI quantities and/or their units is taken into account. For example, the differences between various temperature units are implemented. Non-SI units are implemented if these are accepted to be used in conjunction with the SI.
Furthermore, with Quantities constructs it can be assured that the result of a calculation with certain quantities is commensurable with the quantity to which it is desired to be assigned. Commensurability takes into account the dimension (for the concept of a dimension, see Concepts) of the target quantity and the dimensions of the source quantities. Thus, dimensional analysis and check of correctness is implemented within expressions between Quantities objects.
The package provides for variables, constants, and unique constants. While variables may attain any acceptable value and may change their value during program execution, constants have a value assigned at construction time, which can not be changed later. Unique constants have a fixed value which is assigned at construction time and which can not be changed. For example, natural constants can be implemented as unique constants.
From a programming point of view, Quantities allows the type safe use of quantities within a program. Run time overhead is minimized by means of extensive use of the template possibilities of the C++ language.
It is a goal of the development of Quantities
to clearly separate the concepts of a quantity and a unit. Also, since the conversion of numerical values of a quantity between different units is so important in science, such transformations should be easily possible in a safe way, i.e. only certain acceptable units should be allowed for conversion, and the numerical value should be correctly transformed.
Quantities is based on the SI, which is a "recommended practical system of units of measurement" [BIPM]. It is widely used in science and technology. In particular, it defines seven base units. Quantities is directly related to these units and the corresponding (and other, derived) quantities. For more information in the wider context of metrology, see [VIM].
There is some related code on the web and some of the ideas of Quantities have been discussed before. Of course, Quantities does owe credit to the authors of these programs and articles. However, there are also some important differences. For example, some contributors to the Boost library [Boost] have dealt with problems related to Quantities:
On a cursory view, both these libraries seem to be heavily centered around the `unit' concept, while in Quantities, the quantity is the starting point. Why this is important, is explained elsewhere.
Furthermore, the following souceforge projects are related:
... units, SIUnits (link outdated, see Notes.log!), ...
... boost mpl ...
Some ideas related to this software go back to Barton and Nackman [Barton/Nackman_1994] and [Meyers].
The Quantities package is composed of several sub-packages. Please find more detailed information on these modules here:
The homepage of Quantities is found here, a repository for code is located at sourceforge.
typewriter text
for computer code, commands etc. Text in italics is reserved for items in a command oder in code which have to be substituted by an appropriate value depending on context (e.g., a directory name). Also, emphasized words are written in italics.[White_1998] M.A. White, J. Chem. Educ. 75, 607 - 609 (1998).
[Hall_2002] B.D. White, Software Support for Physical Quantities, presented at the 9th Electronics New Zealand Conference University of Otago, Dunedin, 14-15 Nov, 2002; http://www.irl.cri.nz/msl/MST/phy_quant.html
[BIPM] http://www1.bipm.org/en/si/ (web-site of the Bureau International des Poids et Mesures).
[VIM] http://www.bipm.org/en/publications/guides/vim.html (International Vocabulary of Metrology - Basic and General Concepts and Associated Terms (VIM), document produced by Working Group 2 of the Joint Committee for Guides in Metrology (JCGM/WG 2), 2008).
[Boost] http://www.boost.org
[Units] http://lists.boost.org/boost-announce/2007/04/0126.php
[PQS] http://lists.boost.org/boost-announce/2006/06/0096.php
[Barton/Nackman_1994] J.J. Barton and L.R. Nackman, Scientific and engineering C++: an introduction with advanced techniques and examples, Addison-Wesley, Reading, 1994.
[Meyers] http://www.aristeia.com/sdnotes_frames.html, 10 Cool Things in C++ -- Plus Something Wicked.
Please contact the author of the program at berndspeiser@users.sourceforge.net if you have specific questions about the software. Also, let us know if you use Quantities
in your projects and work. We are interested in your experience with this software.