mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 08:00:48 +03:00
Document use of Kahan vs. vanilla summation
This commit is contained in:
parent
1564671ace
commit
ed36e854ef
1 changed files with 5 additions and 0 deletions
|
@ -1028,6 +1028,11 @@ Kahan summation) algorithm.)
|
||||||
|
|
||||||
For floating point inputs, calculations are made in $(D real)
|
For floating point inputs, calculations are made in $(D real)
|
||||||
precision for $(D real) inputs and in $(D double) precision otherwise.
|
precision for $(D real) inputs and in $(D double) precision otherwise.
|
||||||
|
|
||||||
|
Note that these specialized summing algorithms execute more primitive operations
|
||||||
|
than vanilla summation. Therefore, if in certain cases maximum speed is required
|
||||||
|
at expense of precision, one can use $(D reduce!((a, b) => a + b)(0, r)), which
|
||||||
|
is not specialized for summation.
|
||||||
*/
|
*/
|
||||||
auto sum(R)(R r)
|
auto sum(R)(R r)
|
||||||
if (isInputRange!R && !isFloatingPoint!(ElementType!R) && !isInfinite!R)
|
if (isInputRange!R && !isFloatingPoint!(ElementType!R) && !isInfinite!R)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue