Summator.opOpAssign

Operator overloading.

  1. void opOpAssign(T rhs)
    struct Summator(T, Summation summation)
    void
    opOpAssign
    (
    string op : "+"
    )
    (
    T rhs
    )
    if (
    isMutable!T
    )
  2. void opOpAssign(Summator rhs)
  3. void opOpAssign(T rhs)
  4. void opOpAssign(Summator rhs)
  5. void opAssign(T rhs)

Examples

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);

Meta