inner_fold optimization: maintain vector and scalar sums in parallel, only reduce once at the end instead of once per block.
adapt outer_fold for max_vect_size