C++ for Scientific Computing: 2020-2021

Lecturer

Timetable - Trinity 2021

This course is being run using remote sessions.
Draft timetable (subject to change)
Week Lecture videos released Suggested practical exercises Thursday 10-10:30am Thursday 10:30-11am
Wk 1 Lecture 1, Lecture 2, Lecture 3 Practical sheets 0 and 1 Live Q&A
(Demo: Sheet 1, question 9)
(Discussion: C++ advantages)
Wk 2 Lecture 4, Lecture 5, Lecture 6 Practical sheet 2 Live Q&A Office hours
Wk 3 Lec 6A (on sharing), Lecture 7, Lecture 8, Lecture 9 Practical sheet 3 Live Q&A Office hours
Wk 4 Lecture 10, Lecture 11, Lec 11A (debugging), Lecture 12, Lecture 13 Practical sheet 4 Live Q&A Office hours
Wk 5 - "More practicals" Live Q&A / Office hours
Wk 6 - "More practicals" Live Q&A / Office hours

Prerequisites

Expected
Basic coding of numerical methods in Matlab, Python or another high-level language.
Expected
Basic linear algebra such as matrix-vector multiplication.
C++ level
No previous knowledge of C++ is expected. (The course is intended for programmers/mathematicians who are beginner or novice C++ programmers.)
C++ level
A more precise idea of the content of the course can be gauged from the syllabus below or from contents of the recommended text book. Note that there are differences: in particular, the material in Chapter 11 (MPI) is not covered in this course.

Synopsis

Producing almost any numerical software requires writing codes that manipulate matrices and vectors, making Matlab a natural choice as an introductory programming language for scientific computing. However, the ease of programming in Matlab comes at a cost: the codes take a relatively long time to execute; and the software is commercial. While the use of procedural languages such as Fortran and C will overcome these limitations, they do not allow the straightforward coding of operations between matrices and vectors permitted by Matlab. An alternative approach is to use an object-oriented language such as C++ , where vectors and matrices can be represented as classes. Writing subroutines for these classes that have the same syntax as employed by Matlab allows code developed in Matlab to be translated with minimal effort into C++ code. Such an approach combines the ease of development in the Matlab environment without the associated drawbacks.

Syllabus

C++ programming fundamentals.
  1. Variables and expressions
  2. Input and output
  3. Flow of control: if, switch, while, for
  4. Pointers and references
  5. Arrays
  6. Functions
Object orientation in C++
  1. Concept of a class
  2. Private, public and protected class members
  3. Constructors
  4. Operator overloading
  5. Function overloading - templates
  6. Defining functions that may take default values
  7. Exceptions

Lecture Slides

Practical Assignments

Previous assessments

Supplementary Materials