Hello.

I have following problem to solve:

There is a square matrix 3\times 3, such like this:

\begin{bmatrix} a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}  &a_{32}&a_{33}\end{bmatrix}

So, let's imagine that - for any reason - I would like to "read" the elements of matrix above in following order:

\begin{bmatrix} a_{11}&\to& a_{12}&\to&a_{13}\\&&&&\downarrow\\a_{21}&\to&a_{2  2}&&a_{23}\\\uparrow&&&&\downarrow\\a_{31}&\gets&a  _{32}&\gets&a_{33}\end{bmatrix}

Could I define some kind of a function, which shows the order described above?
It could relate the sequence of steps (x) to matrix's dimensions  (m, n) as follows:
\begin{array}{c|ccccccccccccccccc}<br />
x & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline<br />
m & 0 & 1 & 1 & 1 & 2 & 3 & 3 & 3 & 2 & 2 \\ \hline<br />
n & 0 & 1 & 2 & 3 & 3 & 3 & 2 & 1 & 1 & 2 \end{array}

How could I describe this function? And is there a possibility to define a general description of this type of function for matrices of any m\times n order?

Thinking of this, I imagine some kind of 3D coordinate system where the values of arguments determine the positions of points reffering to the order of "reading" of matrix elements.