moving average of a matrix If I have an $n$ by $n$ matrix $A=\{a_{ij}\}$, I want to get a transformation $\bar{A}=\{\bar{a}_{ij}\}$ of $A$ that each element is the weighted average of itself and its up, down, left, right elements: $\bar{a}_{ij}=\lambda_1a_{ij}+\lambda_2a_{i-1,j}+\lambda_3a_{i,j+1}+\lambda_4a_{i+1,j}+\lambda_5a_{i,j-1}$, for all $i,j$.
(I do not care much about the boundary effect, where $i+1,j+1,i-1,j-1$ are out of bound.)
Is there any matrix form that $\bar{A}$ can be written with in terms of $A$? I mean, something like $\Lambda A$, or $\Lambda_1A\Lambda_1^\top$ or $\Lambda_1A\Lambda_2$? 
 A: Each element is the sum of elements in the same row (left, middle and right) and the same column (up and down) - the central element can either be assigned to the row or the column, so you could equally have had the same column (up, down and middle), and the same row (left and right). 
For contributing elements in the same row, you would need to post-multiply $A$ by matrix $\Lambda_1$, and for contributing elements in the same column you would need to pre-multiply $A$ by matrix $\Lambda_2$.
So you need to have the following:-
$$\bar{A}=A\Lambda_1+\Lambda_2A$$   
Based on the transformation you have, we could set $\Lambda_1$ to be tridiagonal with $\lambda_1$ on the main diagonal
$$\Lambda_1=\begin{bmatrix}
    \lambda_1 & \lambda_5 & 0 & 0 & \cdots & 0 \\
    \lambda_3 & \lambda_1 &\lambda_5 & 0 & \cdots & 0 \\
 0 & \lambda_3 & \lambda_1 & \lambda_5 & \cdots & 0 \\
\vdots & \cdots & \ddots & \lambda_3 & \lambda_1 & \lambda_5 \\
0 & \cdots & 0 & 0 & \lambda_3 & \lambda_1 \\
  \end{bmatrix}$$ 
and set $\Lambda_2$ to be tridiagonal with $0$ populating the main diagonal, as follows:-
$$\Lambda_2=\begin{bmatrix}
    0 & \lambda_4 & 0 & 0 & \cdots & 0 \\
    \lambda_2 & 0 &\lambda_4 & 0 & \cdots & 0 \\
 0 & \lambda_2 & 0 & \lambda_4 & \cdots & 0 \\
\vdots & \cdots & 0 & \lambda_2 & 0 & \lambda_4 \\
0 & \cdots & 0 & 0 & \lambda_2 & 0 \\
  \end{bmatrix}$$ 
An equally valid solution would have been to set the main diagonal of $\Lambda_1$ to $0$, and the main diagonal of $\Lambda_2$ to $\lambda_1$.
