# C++ for Scientific Computing (course not running 19-20, materials for reference) (2019-2020)

**This course will not be running in 2019-20, the materials on this page are for reference and independent study.**

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.

C++ programming fundamentals:

- Variables and expressions;
- Input and output;
- Flow of control: if, switch, while, for;
- Pointers and references;
- Arrays;
- Functions.

Object orientation in C++:

- Concept of a class;
- Private, public and protected class members;
- Constructors;
- Operator overloading;
- Function overloading - templates;
- Defining functions that may take default values;
- Exceptions;
- Derived classes using the example of sparse matrices from Matlab, where a matrix is represented by three vectors.