# Possible Solution

#### Content

$\nu(I,J) := M_r \cdot K \cdot \left\lfloor \frac{I}{M_r} \right\rfloor + J \cdot M_r + (I \bmod M_r)$

## Notes

Actually we get a nice formula due to the fact that indices for rows and columns start at zero:

• The $$I$$-th row of $$\overline{A}_Z$$ belongs to panel $$A_i$$ with $$i = \left\lfloor \frac{I}{M_r} \right\rfloor$$. Panels $$A_0, \dots, A_{i-1}$$ have a total of $$i \cdot M_r \cdot K$$ elements. These must be stored in the buffer in front of the elements from panel $$A_i$$.

So the offset in the buffer is at least $$i \cdot M_r \cdot K = \left\lfloor \frac{I}{M_r} \right\rfloor \cdot M_r \cdot K$$

• In the panel $$A_i$$ all elements with column index smaller than $$J$$ must be stored in front of the elements with column index $$J$$. These are in total $$M_r \cdot J$$ elements.

So the offset must be increased by $$M_r \cdot J$$.

• The element $$a_{I, J}$$ has the row index $$I \bmod M_r$$ in the panel $$A_i$$. All elements in the $$J$$-th column of $$A_i$$ with smaller row-index must be stored in front of $$a_{I,J}$$. These are $$I \bmod M_r$$ elements.

So the offset must be increased by $$I \bmod M_r$$.

## Before you continue

Make sure you understand the formula! :-)