Given a square symmetrical matrix of size NxN, I extract the triangular superior part, omitting the diagonal, and make a vector out of it (I flatten it). In this new vector, the first N-1 elements correspond to the first line of the triangular matrix, the following N-2 to the second and so on. I am now searching for an explicit way to get the coordinate in the initial matrix given the indices in the vector.
Here's an example for N=3:
$\begin{bmatrix}X & a & b \\ X & X & c \\ X & X & X\end{bmatrix}$ become $\begin{bmatrix}a \\ b \\ c\end{bmatrix}$
Given the index of a, here 1, I'd like to find its previous coordinate, (2,1). And so on for all the elements of the vector.
I have tried quite a few things involving the floor function but didn't succeed in anything true. I got close but not quite there. Here's an example that I've tried but didn't work:
N is the dimension of the matrix, i, j are the indices in the matrix, k in the vector.
$$i=N−2−⌊(N−1)^2−k⌋$$
$$j=k+i+1−(N×(N−1)−\frac{(N−i−1)×(N−i−2)}{2})$$
Thanks a lot in advance for your time and effort!