On diagonals that commute with permutations Given a permutation matrix $P$ what are the elements in the set of diagonal matrices $\mathcal R$ with $\pm1$ on diagonal that commute with $P$. That is for what $R\in\mathcal R$ do we have $RP=PR$?
 A: $\newcommand{diag}{\mathrm{diag}}$
$\newcommand{sgn}{\mathrm{sgn}}$
For all $\lambda_1, \dotsc, \lambda_n \in K$ denote by $\diag(\lambda_1, \dotsc, \lambda_n)$ the diagonal matrix with diagonal entries $\lambda_1, \dotsc, \lambda_n$. We fix some $n \times n$ permutation matrix $P$. Because $P$ is a permutation matrix there exists a unique permutation $\sigma \in S_n$ such that
$$
 P e_i = e_{\sigma(i)}
 \quad
 \text{for every $1 \leq i \leq n$},
$$
where $(e_1, \dotsc, e_n)$ denotes the standard basis of $K^n$. For a $n \times n$ matrix $A$ to commute with $P$ we must have $AP = PA$, which is the same as $P^{-1}AP = A$. Now notice that for all $1 \leq i \leq n$
$$
 P^{-1} \diag(\lambda_1, \dotsc, \lambda_n) P e_i
 = P^{-1} \diag(\lambda_1, \dotsc, \lambda_n) e_{\sigma(i)}
 = \lambda_{\sigma(i)} P^{-1} e_{\sigma(i)}
 = \lambda_{\sigma(i)} e_i.
$$
From this we can derive that
$$
 P^{-1} \diag(\lambda_1, \dotsc, \lambda_n) P
 = \diag(\lambda_{\sigma(1)}, \dotsc, \lambda_{\sigma(n)}).
$$
So $\diag(\lambda_1, \dotsc, \lambda_n)$ commutes with $P$ if and only if $\lambda_{\sigma(i)} = \lambda_i$ for every $1 \leq i \leq n$.
If we now partition $\{1, \dotsc, n\}$ into the orbits of the permutation $\sigma$ then the above criterion states that $P$ commutes with $\diag(\lambda_1, \dotsc, \lambda_n)$ if and only if $\lambda_i = \lambda_j$ for all $i,j \in \{1, \dotsc, n\}$ which are in the same orbit.
An example: Take the permutation $\sigma \in S_5$ with $\sigma(1) = 4$, $\sigma(2) = 3$, $\sigma(3) = 2$, $\sigma(4) = 5$ and $\sigma(5) = 1$. (In cycle notation $\sigma = (1 \ 4 \ 5)(2 \ 3)$.) Then the orbits are $\{1,4,5\}$ and $\{2,3\}$. So a diagonal matrix $\diag(\lambda_1, \dotsc, \lambda_n)$ commutes with the permutation matrix $P$ which corresponds to $\sigma$ (i.e. $P e_i = e_{\sigma(i)}$ for every $1 \leq i \leq n$) if and only if $\lambda_1 = \lambda_4 = \lambda_5$ and $\lambda_2 = \lambda_3$.
If $\diag(\lambda_1, \dotsc, \lambda_n)$ is a diagonal matrix with $\lambda_i = \pm 1$ for all $1 \leq i \leq n$ then it follows that $\diag(\lambda_1, \dotsc, \lambda_n)$ commutes with $P$ if and only if $\sgn(\lambda_i) = \sgn(\lambda_j)$ for all $i,j \in \{1,\dotsc,n\}$ which are in the same orbit.
