How does the Kronecker delta work for matrices? I am trying to understand the effect of the kronecker delta function in this expression $\sum_{i,j}(1+\delta_{i,j})M_{ij}$ given that $M$ is a matrix with real-entries.
How does this operation work!?
 A: This is a sum over all entries $M_{ij}$ of $M$, multiplying the diagonal entries $M_{ii}$ by $2$.
A: The Kronecker-delta factor does a "trace," meaning a summation over the diagonal components. Remember that $\delta_{ij}=0$ if $i\ne j$. So, then for any function $f(i,j)$, you'd have
\begin{equation}
\sum_{i,j} \delta_{ij} f(i,j) = \sum_{i=j} f(i,j) = \sum_i f(i,i)
\end{equation}
In your example, then, 
\begin{equation}
\sum_{i,j} (1+\delta_{ij}) M_{ij} = \sum_{i,j} M_{ij} + \sum_i M_{ii}
\end{equation}
The first term is the sum of every element in the matrix. The second term is the sum of the elements on the diagonal.
A: This transformation can be decomposed in the sum of two transformations (supposing of course that the index $i$ and $j$ run over a finite ordered set, otherwise you have to check convergence piece by piece first): $M = \Sigma_{ij} (1+\delta_{ij})M_{ij}=\Sigma_{ij} M_{ij} + \Sigma_{ij}\delta_{ij}M_{ij}.$
The first term gives you the sum of all the elements in the matrix $M_{ij},$ while the second term, since the Kronecker Delta is zero for $i\neq j$, then it gives you the sum of the terms $M_{ij}$ for which $j=i$. So, in resume, this transformation gives you the sum of all the elements of the matrix $M_{ij}$ but the elements $M_{ii}$ are added twice.
Notice that in your question, there are no additional assumptions on the type of matrix $M_{ij}$, therefore, the description given above is general. If by any chance you say that $M_{ij}$ is a square matrix, then the transformation above gives you the sum of all off-diagonal terms of $M_{ij}$ plus twice the trace of $M_{ij}$.
