Summator.opOpAssign

Operator overloading.

  1. void opOpAssign(T rhs)
  2. void opOpAssign(Summator rhs)
  3. void opOpAssign(T rhs)
    struct Summator(T, Summation summation = Summation.Precise)
    void
    opOpAssign
    (
    string op : "-"
    )
    (
    T rhs
    )
    if (
    isMutable!T &&
    (
    summation == Summation.Precise &&
    isFloatingPoint!T
    ||
    summation == Summation.Kahan &&
    isSummable!T
    ||
    (
    summation == Summation.KBN ||
    summation == Summation.KB2
    )
    &&
    (
    isFloatingPoint!T ||
    isComplex!T
    )
    )
    )
  4. void opOpAssign(Summator rhs)
  5. void opAssign(T rhs)

Examples

import std.math, std.algorithm, std.range;
auto r1 = iota(500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a));
auto r2 = iota(500, 1000).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a));
Summator!real 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