I have a matrix of size $n\times m$. I number its elements as follows:
\begin{align} A = \begin{pmatrix} 1 & 2 & \ldots & m\\ m+1 & m+2 & \ldots & 2m\\ \vdots & \vdots & \ddots & \vdots\\ (n-1)*m+1 & (n-1)*m+m & \ldots & n*m \end{pmatrix} \end{align}
Now, my question is: given the element number $x$ where $1 \leq x \leq nm$, find its row and its column. Can I find a general formula for this? I think that if I can write $x$ as $x=(i-1)*m+j$, then I am done.
Indeed, whenever $1 \le x \le nm$ the relevant row can be found by rounding down $(x-1)/m$ to the nearest whole integer, while the column can be found by computing $(x-1) \pmod{m}$.