# How to permute matrix given vector permutation

Let $$M_{i,j} = f(x_i, x_j)$$ where $$\vec{x}$$ is an n-dimensional vector and $$f$$ is some well-behaved function. Now, let $$\tilde{x}$$ be a permutation of the elements of $$x$$. I would like to find the matrix $$\tilde{M}_{i,j} = f(\tilde{x}_i, \tilde{x}_j)$$. I suspect that I can achieve this the following way:

1. Compute matrix $$M$$
2. Permute rows of matrix $$M$$
3. Then, permute columns of matrix $$M$$ using the same permutation

Is this true?

• Yes, but at one of the steps (mostly at 2.) you need to take the inverse permutation. – Berci Apr 15 at 14:51
• @Berci I'm struggling with this a bit. When I do the math, it seems like the standard $RMR^T$ transform. But when I think about it logically, it does not make sense. In the above notation, there is no fundamental difference between the rows dimension and the columns dimension. Why should one of them be permuted differently than the other? – Aleksejs Fomins Apr 16 at 8:39

1. $$\tilde{M}_{ij} = \sum_{kl}R_{ik} R_{jl} M_{kl}$$
2. $$\tilde{M} = RMR^T$$