Compute smoothness matrix.