Gaussian Elimination with Partial Pivoting

Gaussian elimination is a direct method for solving a linear system of equations. A linear system is a set of simultaneous equations (linear) in several variables. In theory, solving such a system algebraically is straightforward. First, we eliminate the first variable either by substitution or appropriate row operations. We then continue to eliminate the second … Read more

The Bridge Pattern

The Bridge pattern is a structural design pattern in which abstraction is used to separate the interface from the implementation so that the two can be modified independently. The Bridge pattern is particularly useful when developing code which might need to run on different platforms. For example, suppose you want to develop a user interface … Read more

Asynchronous Programming in C#

Tasks In .NET, the Task class enables us to run jobs asynchronously. It offers a more high-level framework than we saw in the previous post on threading, which means we don’t have to get involved with mutexes and signalling. There are two versions of the task class: the non-generic Task class which is for tasks … Read more

Categories C#

Threading in C#

Threads are an important concept in asynchronous programming. In this post we will cover creating threads and give a brief overview of some of the low-level synchronisation classes in .NET. Finally we look at the .NET thread pool which allows a series of tasks to be run in parallel. Creating threads The Thread class can … Read more

Categories C#

Lambda Expressions (C#)

Lambda expressions allow us to define anonymous expressions. You can use lambda expressions where where you might use a delegate function. Lambda expressions are defined using the lambda operator =>. There are two types of lambda expressions: An expression lambda which is defined by an expression. A statement lambda which is defined by a statement … Read more

Categories C#

Delegates and Events

A delegate is an object that holds a reference to a method. A delegate can be used to implement a callback mechanism, for example to receive notification of an event such as a user clicking on a button. Delegates are also useful when we consider of the principle of separation of concerns. For example, we … Read more

Categories C#

In-class Initialisation of Data Members

In C++03, only const static members of integral type can be initialised directly in the class. C++11 allows members to be initialised in-class. class Test { public: const static int x = 0; // C++03 int y = 0; // C++11 only }; We can also initialise objects e.g. strings: class Test { public: std::string … Read more

Smart Pointers

The C++11 standard introduced two new smart pointers, unique_ptr and shared_ptr. These new classes are very helpful for managing dynamically allocated memory. The difference between these two smart pointers is that unique_ptr implies exclusive ownership to a block of memory, whereas shared_ptr allows for multiple ownership. Both these smart pointers are defined in the memory … Read more

Lambda Expressions

Lambda expressions allow you to define anonymous functions in your C++ code. A good way to demonstrate lambda expressions in practice is to show how they can be used in conjunction with some of the algorithms in the standard library. For example, here is how we would sort a list of integers in C++03: bool … Read more

Move Semantics

In the previous post on Rvalue References, we introduced lvalues, rvalues and temporary objects. The purpose of that post was to lay the groundwork for a discussion on move semantics, an important feature which was introduced in the C++11 standard. We again consider the example of a Vector class for 3D geometry. The definition file … Read more