import mir.math.common; import mir.ndslice.topology: iota, map; auto r1 = iota(500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); auto r2 = iota([500], 500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); Summator!(real, Summation.precise) s1 = 0, s2 = 0.0; foreach (e; r1) s1 += e; foreach (e; r2) s2 -= e; s1 -= s2; s1 -= 1.7L.pow(1000); assert(s1.sum == -1);
Operator overloading.