computing the sums without storing the matrix