Optimized scalar_sum energy/virial reduction