uxarray.utils.computing._norm_l

Contents

uxarray.utils.computing._norm_l#

uxarray.utils.computing._norm_l(x)#

Compute the L2 norm (Euclidean norm) of a vector using a compensated algorithm.

This function calculates the L2 norm of a vector, employing a compensation technique to reduce numerical errors during the computation. It involves computing the sum of squares of the vector elements in a numerically stable way.

Parameters:

x (list of float) – The vector whose L2 norm is to be computed.

Returns:

The compensated L2 norm of the vector.

Return type:

float

Examples

>>> _norm_l([1.0, 2.0, 3.0])
3.7416573867739413

Vincent Lef`evre, Nicolas Louvet, Jean-Michel Muller, Joris Picot, and Laurence Rideau. Accurate Calculation of Euclidean Norms Using Double-Word Arithmetic. ACM Transactions on Mathemat- ical Software, 49(1), 1–34, March 2023. 10.1145/3568672