helper function to make difference matrix operator