The space of matrices that commute with a given matrix $A\in \mathbb{C}^{n\times n}$ is a subspace of the vector space of all matrices $\mathbb{C}^{n\times n}$.
There must exist a projection operator upon this subspace, some $P_A$ such that $$\forall M \in \mathbb{C}^{n\times n}: [P_A M,A]=0$$ Question: Is there some useful expression for $P_A$ in terms of $A$?
Context
I'm looking for a way to interpolate matrices without breaking commutation. For example, I may want to construct $$f:[0,1]\rightarrow \mathbb{C}^{n\times n}$$ $$g:[0,1]\rightarrow \mathbb{C}^{n\times n}$$ knowing $f(0),f(1),g(0),g(1)$ and $[f(0),g(0)]=[f(1),g(1)]=0$, in such at way that $[f(x),g(x)]=0$ remains true for all $x$.
Consider the case where $A$ is diagonalizable with $n$ distinct eigenvalues: $A = S \Lambda S^{-1}$ where $\Lambda$ is diagonal. Then it's easy to see that the matrices that commute with $A$ are all those that are diagonalized using the same $S$: $\{M: \;S^{-1} M S \text{ is diagonal}\}$. A projection on this space is $P_A(M) = S P_D(S^{-1} M S) S^{-1}$ where $P_D$ makes all off-diagonal elements $0$ and leaves the diagonal elements unchanged: $$P_D(X)_{ij} = \cases{X_{ii} & if $i=j$\cr 0 & otherwise}$$