# Full storage format for matrices

#### Content

Goal: Getting familiar with the full storage format for matrices.

## Exercise

In this first exercise you are asked to write a small C program that initializes a $$7 \times 8$$ col major matrix and then prints the matrix. The program should consist of three functions initMatrix, printMatrix and main:

• Function initMatrix initializes an $$m \times n$$ matrix. The initialization enumerates the matrix elements row-wise from $$1$$ to $$m\cdot n$$.

E.g. in the case where $$m=2$$ and $$n=3$$ the matrix afterwards looks like this:

$\begin{pmatrix}a_{0,0} & a_{0,1} & a_{0,2} \\a_{1,0} & a_{1,1} & a_{1,2} \\\end{pmatrix}\leftarrow\begin{pmatrix}1 & 2 & 3 \\4 & 5 & 6\end{pmatrix}$
• Function printMatrix is supposed to print the content of a matrix.

• In function main, define and initialize local variables m, n, A, incRowA, incColA that describe the storage of a matrix:

• m and n should be of type size_t,

• A should be a pointer to double,

• incRowA and incColA should be of type ptrdiff_t.

After allocating memory for the matrix elements, initialize and print the matrix. Before main returns release the memory.