Is there an easier way to take the sum of a matrix?