Skip to content

num::kernel::norm

Defined in header <kernel/vector.hpp>

template <std::floating_point T>
T norm(const T *x, idx n) noexcept;

Euclidean norm \(\|x\|_2\), safe from overflow and underflow.

It uses sqrt(norm_sq(x, n)) when that sum is finite and nonzero, and a rescaled second pass otherwise, since squaring overflows past about 1.3e154 and underflows below 1.5e-154.