sumOfLog2s

Computes accurate sum of binary logarithms of input range r.

ElementType!Range
sumOfLog2s
(
Range
)
(
Range r
)
if (
isInputRange!Range &&
isFloatingPoint!(ElementType!Range)
)

Examples

import std.math, std.numeric;
assert(sumOfLog2s(new double[0]) == 0);
assert(sumOfLog2s([0.0L]) == -real.infinity);
assert(sumOfLog2s([-0.0L]) == -real.infinity);
assert(sumOfLog2s([2.0L]) == 1);
assert(sumOfLog2s([-2.0L]).isNaN());
assert(sumOfLog2s([real.nan]).isNaN());
assert(sumOfLog2s([-real.nan]).isNaN());
assert(sumOfLog2s([real.infinity]) == real.infinity);
assert(sumOfLog2s([-real.infinity]).isNaN());
assert(sumOfLog2s([ 0.25, 0.25, 0.25, 0.125 ]) == -9);

Meta