The Design of C++ Classes for Scientific Computing
Soren Nielsen
University of Texas
Nielsen@guldfaxe.bus.utexas.edu
We consider the design of C++ classes for abstract data types
that are useful in scientific computing, such as vectors and
matrices that appear and disappear dynamically, have varying sizes,
may be sparse, and that respond to the natural arithmetic operators.
These classes should be memory-safe, in the sense that all dynamically
allocated memory is automatically released when no longer needed,
and copy-efficient in the sense that no data should be unnecessarily
copied when objects are passed to or from functions and operators.
A framework for designing such classes is developed. We introduce
as a simple example the case of a dynamic array of numbers. We then expand
this framework to more general container classes, exemplified by a dynamic
array with elements of any type by use of a template. The design of C++ and
possible extensions to the language are discussed informally along the way.
Society of Computational Economics
Second International Conference on
Computing in Economics and Finance
Geneva, Switzerland, 26-28 June 1996