uxarray.utils.computing._vec_sum

Contents

uxarray.utils.computing._vec_sum#

uxarray.utils.computing._vec_sum(p)#

Compute the sum of a vector using a compensated summation algorithm.

This function calculates the sum of the elements in a vector using a compensated summation algorithm to reduce numerical errors.

Parameters:

p (list of float) – The vector whose elements are to be summed.

Returns:

The compensated sum of the elements in the vector.

Return type:

float

Examples

>>> _vec_sum([1.0, 2.0, 3.0])
6.0

Takeshi Ogita, Siegfried M. Rump, and Shin’ichi Oishi. 2005. Accurate Sum and Dot Product. SIAM J. Sci. Comput. 26, 6 (2005), 1955–1988. https://doi.org/10.1137/030601818