Skip to main content

C++ for Scientific Computing [C]:  2008-2009

Lecturer

Degrees

2009: Trinity TermMSc in Mathematical Modelling and Scientific Computing

Term

Learning outcomes

Assessment

A class of vectors and matrices should be written. Code, similar to Matlab code, should then be written using these classes to solve one of the following problems:

1. The implementation of a numerical technique such as an implicit solver for the heat equation in one dimension
2. The replication of a Matlab function such as cgs, the conjugate gradient solver

The code will be assessed based on the following criteria: 1. The clarity with of the code and documentation 2. Whether the code achieves its objectives

Advanced concepts from C++ will not be expected.

Prerequisites

Basic coding of numerical methods in Matlab.

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
  8. Derived classes using the example of sparse matrices from Matlab, where a matrix is represented by three vectors

Taking our courses

This form is not to be used by students studying for a degree in the Department of Computer Science, or for Visiting Students who are registered for Computer Science courses

Other matriculated University of Oxford students who are interested in taking this, or other, courses in the Department of Computer Science, must complete this online form by 17.00 on Friday of 0th week of term in which the course is taught. Late requests, and requests sent by email, will not be considered. All requests must be approved by the relevant Computer Science departmental committee and can only be submitted using this form.