further optimized summation over independent dimensions