Fast sum along dimensions over contiguous arrays