An Introduction to the Boost Library
C++ continues to evolve and already STL is part of the official standard. We would like to discuss some new developments that are taking place and in particular we give an overview of the boost library (www.boost.org), a suite of useful C++ libraries containing functionality in the form of template classes:
Multiarray: defines a generic interface to multidimensional containers
Random numbers: contains a number of classes for generators and statistical distributions
Property map: classes that embody key-value pairs and definition of the corresponding access (for example read and write)
Smart pointers: objects that store pointers to dynamically allocated (heap) objects
Graph library: a C++ library implementing graphs, networks and related graph algorithms
The authors (as well as many other software developers) have developed a subset of the functionality contained in these libraries. For example, in Duffy 2004 and Duffy 2006 we have implemented a template Property Map class with properties similar to that in boost; furthermore, we have created classes for two-dimensional matrices and three-dimensional tensors using nested STL classes. If we were to build such classes again, we would choose to use the boost library as underlying substrate.
We give a short description of the functionality in the above libraries. At this stage we avoid dealing with the C++ details on how to use these libraries in an application (they will be discussed later). We summarise each library as a list of features:
Multiarray
Array classes for n-dimensional data
Accessing the elements of array using () and [] operators
Creating views of an array having the same or less dimensions
Determining storage ordering of data (C-style, Fortran-style or user-defined)
Defining or changing array index (zero is default)
Changing an array?s shape
Resizing an array (increasing or decreasing the extent of a dimension in an array)
Random Numbers
Linear congruential generators
Mersenne Twister generator
Lagged Fibonacci generators
Classes for continuous statistical distributions
Classes for discrete statistical distributions
Property Maps
Key-value pair concept
Readable and writable data
Support for built-in C++ data types
Applicability to Boost Graph Library (BGL)
Smart Pointers
Sole ownership to single objects and arrays
Shared ownership of objects and arrays
Shared ownership of objects with embedded reference counting
The gradual introduction of these features in applications will promote the reliability, maintainability and efficiency of your software. We shall see next to use these libraries and to apply them to the Monte Carlo method and other applications in finance.
In the next blogs we shall give some examples in C++ and applications to the Monte Carlo method.