21.1 Introduction and Objectives
In this chapter we concentrate on implementing the algorithms that describe the finite difference schemes from Chapter 20. We use a combination of styles that C++ has to offer to show what is possible. Chapter 20 deals with the mathematics of the problem and associated numerical methods, whereas this chapter focuses on how to map the algorithms to C++. There is thus a clear separation of concerns. More precisely, the goals in this chapter are:
- Το create a seamless mapping from FD algorithms to C++, thus helping us to create code that is built to be maintained and extended. We achieve this end by using system decomposition methods and design patterns.
- Το experiment with a range of FD schemes (some of which are new in finance) and determine how stable and accurate they are.
- Having determined that a scheme is to our liking, to optimise the code by modifying the design or the code in some way in order to improve the performance.
We discuss a number of design and coding styles to satisfy the first two goals. We then measure the run-time performance of the code to determine whether it satisfies the third goal.
The skills developed in this chapter can be applied to a range of applications. We make this claim based on how we designed problems in Chapter 9. The key issues are to decide what the initial high-level architecture is going to be and how we design classes, class hierarchies and polymorphic ...