0. Table of Content

1. Computing with Matrices and Vectors

1.1 Fundamentals

1.1.1 Notations

In this lecture we denote column vectors with $x$ and row vectors with $x^T$. For example, $\mathbb{K}^n$ denotes the vector space of column vectors whereas $\mathbb{K}^{1,n}$ denotes the vector space of row vectors. We denote sub vectors with $(x)_{k:l} = [x_k, \ ..., \ x_l]^T, \ 1 \leq k \leq l \leq n$.

We denote matrices with $X$. In this lecture, matrices are two-dimensional arrays of real or complex numbers:

$$ A := \begin{bmatrix} a_{11} & \cdots & a_{1m} \\ \vdots & & \vdots \\ a_{n1} & \cdots & a_{nm} \end{bmatrix} \in \mathbb{K}^{n,m} $$

Here, $\mathbb{K}^{n,m}$ denotes the vector space of $n \times m$-matrices, where $n$ is the number of rows and $m$ is the number of columns. We denote matrix blocks with $(A){k:l,r:s} := [a{ij}]_{i = k,...l; \ j = r,...,s}$. We define the (hermitian) transposed matrix as:

$$ A^H := \begin{bmatrix} a_{11} & \cdots & a_{1m} \\ \vdots & & \vdots \\ a_{n1} & \cdots & a_{nm} \end{bmatrix}^H := \begin{bmatrix} \overline{a}{11} & \cdots & \overline{a}{n1} \\ \vdots & & \vdots \\ \overline{a}{1m} & \cdots & \overline{a}{mn} \end{bmatrix} $$

1.2 Software and Libraries

1.2.1 Eigen

Eigen is a header-only C++ template library designed to enable easy, natural and efficient numerical linear algebra: it provides data structures and a wide range of operations for matrices and vectors.

A generic matrix data type is given by the templated class:

Eigen::Matrix<typename Scalar, int RowsAtCompileTime, int ColsAtCompileTime>

Here Scalar is the underlying scalar type of the matrix entries, usually either double, float or complex<>.

Matrix and vector data types in Eigen

#include <Eigen/Dense>

template <typename Scalar>
void eigenTypeDemo(unsigned int dim) {
	// General dynamic matrices
	using dynMat_t = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
	// Dynamic column vectors
	using dynColVec_t = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
	using index_t = typename dynMat_t::Index;
	using entry_t = typename dynMat_t::Scalar;
	// Declare vectors of size 'dim', not yet initialized
	dynColVec_t colvec(dim);
	// Initialisation through component access
	for(index_t i = 0; i < colvec.size(); ++i) colvec[i] = (Scalar)i;
}

The following convenience data types are provided by Eigen: