For example, consider a 1D data $\begin{bmatrix} a\\ b\\ c \end{bmatrix}$.
I can represent forward difference operator as matrix
$\nabla_n = \begin{bmatrix} -1&1& 0\\ 0&-1&1\\ 0&0& 0\end{bmatrix}$ (neumann boundary condition) and
$\nabla_p = \begin{bmatrix} -1&1& 0\\ 0&-1&1\\ 1&0& -1\end{bmatrix}$ (periodic boundary condition).
Then we have
$\nabla_n^T \nabla_n=\begin{bmatrix} 1&-1& 0\\ -1&2&-1\\ 0&-1& 1\end{bmatrix}=-\Delta_n$ (neumann laplacian) and
$\nabla_p^T \nabla_p=\begin{bmatrix} 2&-1& -1\\ -1&2&-1\\ -1&-1& 2\end{bmatrix}=-\Delta_p$ (periodic laplacian).
My question is that I don't know how to represent Dirichlet boundary condition. I thought
$\nabla_d = \begin{bmatrix} -1&1& 0\\ 0&-1&1\\ 0&0& -1\end{bmatrix}$,
but then
$\nabla_d^T \nabla_d=\begin{bmatrix} 1&-1& 0\\ -1&2&-1\\ 0&-1& 2\end{bmatrix} \neq -\Delta_p = \begin{bmatrix} 2&-1& 0\\ -1&2&-1\\ 0&-1& 2\end{bmatrix}$.
How can I represent Dirichlet case?