Find the sum of a vector
naivesum(x)
kahansum(x)
pwisesum(x)| x | a vector of numbers to be summed |
|---|
the sum
naivesum calculates the sum of a vector by keeping a counter
and repeatedly adding the next value to the interim sum.
kahansum uses Kahan's algorithm to capture the low-order
precision loss and ensure that the loss is reintegrated into the
final sum. pwisesum is a recursive implementation of the
piecewise summation algorithm that divides the vector in two and adds
the individual vector sums for a result.