Math 612  Computational Finance

C++ lectures

Class Schedule:        Thursdays, 6:40-8:00
Office Hours:            Thursdays, 8:00-9:00
Location:                   Hill 705. 

External Links    Sample Programs    Course Plan    Assignments


Objective of the class

To enable students with minimal knowledge of C or Java to learn programming in C++.  Refresh the basic programming constructs, discuss common errors, good programming practices etc.   Learn practical application of C++ to computational finance.

Prescribed text

Daoqi Yang, C++ and Object-oriented Numeric Computing for Scientists and Engineers, Springer 2000, ISBN 0387989900

Course Plan

This course plan lists the topics that shall be covered.  The corresponding chapters of the text book are also listed so that students can go into complete details if they are omitted in the time limited lecture period. 

Class
Chapters
Topics
Comments/Assignments/Links
1
1 & 2
Expressions - syntax and value;   Variables - meaning, syntax, types, local/global/static;   type promotion/ automatic typecasting.

We followed Constant and Variable types, Expressions and operators from
http://www.its.strath.ac.uk/courses/c/
Please look at the sample program explaining the first c prgram
The above file has lot of comments, there is a stripped down version of the program also.

2
3
Functions - arguments, return values, inline, recursion;   Structures;  Pointers and arrays - syntax, meaning, pointer arithmetic, examples, use case/advantages of pointer;  Main function; Example of static variable in function;  Completed operators not covered in class #1;  Math standard library functions. skipped enumerations and reference from text

3
4
Namespaces - syntax, meaning, examples, use cases;   Introduce  scoping operator ::, new and delete operators  ;   Class - members, constructor, destructor, visibility;  Program structure - h files, cpp files;  Overview of make process - compilation, linking;  Libraries.
skipped namespace alias, unnamed namespace as too specific
skipped string and stream library (I/O related and formatting) for later
skipped makefile in overview of make process;
Promoted class before Ch 5 because of its conceptual relationship to namespace. Apologies to Daoqi Yang for changing the flow.
4
5 & 6
Class - definition, members, methods, meaning of method call on object, public and private, constructor, destructor, non default constructors,  static members - example and use case, member initial list (introduced : )
Difference of definition and declaration; 
Operator overloading.  also introduce default parameters to methods and functions - examples and use case.
Note: delayed introduction of default value of arguments from Ch 3 because it has a lot in common with the concept of overloading.
Note: skipped pointer to method and Section 6.5 "deferred overloading" as too specific
Please find a sample program for matrix class
5
7 & 8
Templates - classes, functions, multiple arguments, usage example
Inheritance - virtual functions & destructor, member visibility, types of inheritance, use of inheritance
Assignment #1 due February 21.
Please find a sample program for vector template and a metaprogramming sample for factorial
6
Review

Check the option valuation binomial tree program
7
9 & 10.1
Exceptions: keywords try, catch, throw and examples.
Uses of exceptions - non local error handling, fine grained error handling;
Standard library template classes and their common methods: vector, list, stack, queue, map, set;  efficiency considerations in choice of data structure.
Iterators - usage, examples, reverse, forward, and const.
Quick introduction to sort algorithm to be covered next time.
Suggested problems: 10.4.2; 10.4.6 in the Yang text book.
Template example programs:
Example first program at Stroustrup's C++ site
Example program that prints a vector< vector<T> >
Also check SGI's site at bottom.
8
10.2


9
10.3


10
10.4


11
11.1 & 11.2


12
11.3 & 11.4


13
11.5 & 11.6


14
Review



Useful Links

How to compile a C++ program on UNIX
A small complete C program
Understanding common compiler errors thrown by g++  NOTE: Search engines are quite useful for understanding even the rare errors, just put the error string given by compiler in a double quote like: "error: n is undefined" and you can get quick help.
Public/Private/Protected access rules for C++
.
SGI's introduction to STL


Sample Programs

1. Please look at the sample program explaining the first C prgramThe file has lot of comments, there is a stripped down version of the program also.
2. S
ample program for matrix class
3. Sample program for vector template
4. Template metaprogramming example program for factorial function
5. Option valuation binomial tree program

Assignments

1. Assignment #1 due February 21
2.
3.