An Ada (Trade Name) Package for Dimensional Analysis
CALIFORNIA UNIV BERKELEY COMPUTER SCIENCE DIV
Pagination or Media Count:
This paper illustrates the use of Adas abstraction facilities- notably operator overloading and type parameterization-to define an oft- requested feature a way to attribute units of measure to variable and values. The definition given allows the programmer to specify units of measure for variables, constants, and parameters checks uses of these entities for dimensional consistency allows arithmetic between them, where legal and provides scale conversions between commensurate units. It is not constrained to a particular system of measurement such as the metric or English systems. While the definition is in standard Ada and requires nothing special of the compiler, certain reasonable design choices in the compiler, discussed here at some length, can make its implementation particularly efficient. Dimensional analysis is a consistency check common in scientific and engineering computations. It consists of verifying that uses of numerical quantities conform to their declared units of measure-for example, that measures of length are not added to measures of time and that quotients of distance and time are treated as velocities. In many ways, dimensional analysis resembles strong typing, as found in Ada and other modern programming languages.
- Computer Programming and Software