Hello,
[linalg.algs.blas1.nrm2]/3 specifies the return value of vector_two_norm as "The square root of the sum of the square of init and the squares of the absolute values of the elements of v." (emphasis added). But the reference implementation provides
|
return init + ssq_res.scaling_factor * sqrt(ssq_res.scaled_sum_of_squares); |
which pulls init out of the square-root-of-sum-of-squares. If the purpose is to be able to calculate a two-norm in stages, then the language in [linalg] is the correct way to do it, which is why I'm filing a bug instead of an LWG issue. But LMK if I have it the other way around.
As an aside, however, the Standard language is more difficult to implement robustly because init can be complex. That is, $\sqrt{z^2 +x^2}$, with $z\in ℂ,x\in ℝ$ is harder to compute than $\sqrt{x^2+y^2}$ with $\{ x,y \} \in ℝ$.