fn segment_cost( cs: &CumulativeSums, start: usize, end: usize, dim: usize, ) -> f64
Cost of segment [start, end): sum of squared deviations from segment mean.