uxarray.utils.computing._sum_of_squares_re

uxarray.utils.computing._sum_of_squares_re#

uxarray.utils.computing._sum_of_squares_re(vec)#

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

This function calculates the sum of squares of the elements in a vector, employing a compensation technique to reduce numerical errors.

Parameters:

vec (list of float) – The vector whose elements’ squares are to be summed.

Returns:

The compensated sum of the squares of the elements in the vector.

Return type:

float

Examples

>>> _sum_of_squares_re([1.0, 2.0, 3.0])
14.0

Stef Graillat, Christoph Lauter, PING Tak Peter Tang, Naoya Yamanaka, and Shin’ichi Oishi. Efficient Calculations of Faith- fully Rounded L2-Norms of n-Vectors. ACM Transactions on Mathemat- ical Software, 41(4), Article 24, 2015. 10.1145/2699469. Available at: https://doi.org/10.1145/2699469.