Invertibility of Matrix mapping $f(X) = DX + XD$ Consider the set of $n*n$ matrices.
If $D$ is a diagonal matrix, and the linear transformation from the set of $n*n$ matrices to itself is defined as
$$f(X) = DX + XD$$Is the mapping invertible?
Here are some observations I made. Obviously, if all diagonal entries are 0, then it's not injective.
If $$D =     \left [ \begin{matrix}
    1 & 0 \\
    0 & 0 \\
  \end{matrix} \right ]$$ Then applying $f(X)$ to any matrix will lose the element on the lower right corner of $X$.
So my guess is that every element in $D$ should be nonzero. But is that enough for our mapping to be invertible?
edit: Existence of differentiable matrix maps $M(3,\mathbb{R}) \rightarrow M(3,\mathbb{R})$ This is where the relevant question comes from. I'm trying to figure out how this might be related.
 A: Let $\operatorname{diag}(c_1, \ldots, c_n) = D$. Multiplying an $n \times n$ matrix $X$ to $D$ can be simply described: $XD$ is the matrix $X$, with its first column scaled by $c_1$, its second column scaled by $c_2$, etc up to $n$. Similarly, the matrix $DX$ is the matrix $X$ with the first row scaled by $c_1$, its second row scaled by $c_2$, etc.
Therefore, if we let $(x_{ij})_{i,j=1}^n = X$, then
$$f(X) = ((c_i + c_j)x_{ij})_{i,j=1}^n.$$
Now, we should investigate the kernel of $f$, as this will tell us if $f$ is injective. Since $f$ is an operator on a finite-dimensional space, this is equivalent to $f$ being invertible.
Note that if $c_i + c_j = 0$ for some $i, j$ (including possibly $i = j$, i.e. if $c_i = 0$ for some $i$), then we get a non-trivial kernel. Specifically, if $c_i + c_j = 0$, then any matrix $X$ formed by putting $0$ everywhere except the entry in the $i$th row and the $i$th column will be in the kernel of $f$, even though $X$ is not necessarily $0$. Thus, in this case, $f$ is not invertible.
Otherwise, if $c_i + c_j \neq 0$ for all $i, j$, then $(c_i + c_j)x_{ij} = 0 \implies x_{ij} = 0$, and hence $X = 0$. That is, under this condition, the kernel of $f$ is trivial, hence $f$ is invertible.
So, here's an example where $f$ is invertible:
$$D = \begin{pmatrix} 2 & 0 \\ 0 & -3 \end{pmatrix},$$
but here's another example where $f$ is not invertible:
$$D = \begin{pmatrix} 6 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -6 \end{pmatrix}.$$
A: I think it will be an alternative way to check whether this linear transformation is invertible by checking whether its corresponding matrix under a set of basis is invertible.
Assume $$D_{n\times n}=\begin{bmatrix}\lambda_1 & 0 & \cdots & 0 \\ 0 & \lambda_2 & \cdots & 0 \\ \cdots & \cdots & \cdots & \cdots \\0 & 0 & \cdots & \lambda_n\end{bmatrix}$$, and choose conventional orthonormal basis $\{E_{ij}\},1\leq i\leq n,1\leq j\leq n$, in which $$E_{ij}=\left[e_{xy}\right],e_{xy}=\begin{equation}\begin{cases}1, & x=i,y=j \\ 0, & \text{otherwise}\end{cases}\end{equation}$$
Then $$f(E_{ij})=(\lambda_i+\lambda_j)E_{ij}$$
Thus its corresponding matrix under $\{E_{ij}\}$ is
$$
\begin{bmatrix}
\lambda_1+\lambda_1 & 0 & \cdots & 0 \\ 
0 & \lambda_1 + \lambda_2 & \cdots & 0 \\ 
\cdots & \cdots & \cdots & \cdots \\ 
0 & 0 & \cdots & \lambda_n+\lambda_n \end{bmatrix}_{n^2\times n^2}$$
In order to let this matrix be invertible, it is easy to know this is equivalent to let $$\lambda_i+\lambda_j\neq 0,1\leq i\leq n,1\leq j\leq n$$
This should be the condition.
