Thomas Russell: Programmer & Designer
Have a browse of my thoughts!

Recent Posts - What I've been saying

Adding a Generic p-norm in Modern C++

In this article, I will show how to use modern C++ features such as fold expressions, variadic templates and type-traits to make a safe, stable and generic $p$-norm function. Read more »

Writing a Tensor class in Modern C++

As promised in my article about the mathematics of solving the multidimensional Poisson equation, I am beginning writing about the process of writing a parallelized solution to the Poisson Equation by successive over-relaxation. This article will be about writing a tensor class in modern C++, as we will need a multidimensional grid for our Poisson solver.

Mathematically speaking, a Tensor is a multidimensional object over some appropriate field. In this case we will be considering simple fields, real numbers (to floating-point precision), integers (modulo some appropriate power of 2) and complex numbers. Tensors are mathematically-rich objects, with their own notation and algebras embedded in Ricci calculus, but here we will only be writing a basic Tensor class equipped with a few useful operators, however, it is an easily extendable object, so can easily be modified for most general purposes. Read more »

Exporting a Matrix from C++ to Mathematica

In my previous two posts: Solution to the Laplace Equation in C++ using successive over-relaxation and Solution to the Poisson Equation in C++ using Successive Over-relaxation I generated a matrix in C++ and computed the elements of it using a numerical method. I then used Mathematica to visualize the data and compare it to the analytic solution to demonstrate the validity of the methods.

In this blog post I will demonstrate how to export a matrix from C++ (which I will be representing simplistically using a std::vector<std::vector<T>>) to Mathematica using the MatrixMarket (.mtx) format.

The reason I have chosen this particular format for exporting a matrix is because it is space efficient at representing sparse matrices and a NIST standard which is natively handled by many systems, including Mathematica.

N.B: The .cpp file is available in ZIP format at the bottom of this post. Read more »

OCR C3 & C4 Revision Guide

I’m currently in the process of applying to internships, and as I was digging around my Google Drive (which is what I’m using to draft my cover letters) I came across a revision guide I made a couple of years ago to help people with OCR A-level maths revision (specifically the C3 and C4 sections).

I’m sure that there are bits missing, but it covers 5 basic topics:

  1. Lines and basic linear algebra
  2. Differentiation and Integration
  3. Numerical Methods: Root finding & Quadrature methods
  4. Algebra and Functions
  5. Trigonometry

I just thought I’d release it here to see if it can possibly help anyone! (N.B: The wide margins are for notes to self whilst reading).

Download Link: C3 & C4 Revision Guide

Proving the det(AB) = det(A)det(B) relation using the Levi-Cevita tensor

I recently had to prove that $$\det(\mathbf{A}\mathbf{B}) = \det(\mathbf{A})\det(\mathbf{B})$$

I thought that it would be an interesting exercise to show this using the standard definition of the determinant of a matrix that physicists usually give (using Einstein summation):

$$\det(\mathbf{A}) \triangleq \varepsilon^{i_{1}\cdots i_{n}} a_{1 i_{1}} \cdots a_{n i_{n}}$$

We note that if we denote $\mathbf{C} = \mathbf{A}\mathbf{B}$, then we have $c_{ij} = a_{ik}b_{kj}$, and thus:

$$\begin{align*}\det(\mathbf{C}) &= \varepsilon^{i_{1}\cdots i_{n}}c_{1 i_{1}}\cdots c_{n i_{n}} \\
&= \varepsilon^{i_{1}\cdots i_{n}} a_{1 k_{1}}b_{k_{1} i_{1}} \cdots a_{n k_{n}}b_{k_{n} i_{n}} \\
&= a_{1 k_{1}}\cdots a_{n k_{n}} \varepsilon^{i_{1} \cdots i_{n}}b_{k_{1} i_{1}}\cdots b_{k_{n} i_{n}}\end{align*}$$

Read more »

Designed and Produced by Thomas Russell © 2014-2017

Log-in | Register