Skip to content

Commit 4f3dba4

Browse files
committed
New issue from Mark Hoemmen: "Insufficient specification of vector_two_norm and matrix_frob_norm"
1 parent f3de4f0 commit 4f3dba4

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

xml/issue4315.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4315" status="New">
5+
<title>Insufficient specification of `vector_two_norm` and `matrix_frob_norm`</title>
6+
<section>
7+
<sref ref="[linalg.algs.blas1.nrm2]"/>
8+
<sref ref="[linalg.algs.blas1.matfrobnorm]"/>
9+
</section>
10+
<submitter>Mark Hoemmen</submitter>
11+
<date>14 Aug 2025</date>
12+
<priority>99</priority>
13+
14+
<discussion>
15+
<p>
16+
The wording for `vector_two_norm` <sref ref="[linalg.algs.blas1.nrm2]"/> and
17+
`matrix_frob_norm` <sref ref="[linalg.algs.blas1.matfrobnorm]"/> has two issues.
18+
</p>
19+
<ol>
20+
<li><p>Their <i>Returns</i> clauses say that the functions return the "square
21+
root" of the sum of squares of the initial value and the absolute
22+
values of the elements of the input `mdspan`. However, nowhere in
23+
<sref ref="[linalg]"/> explains how to compute a square root.</p>
24+
<ol style="list-style-type: none">
25+
<li><p>1.a. The input `mdspan`'s `value_type` and the initial value type
26+
are not constrained in a way that would ensure that calling
27+
`std::sqrt` on this expression would be well-formed.</p></li>
28+
<li><p>1.b. There is no provision to find `sqrt` via argument-dependent
29+
lookup, even though <sref ref="[linalg]"/> has provisions to find `abs`, `conj`,
30+
`real`, and `imag` via argument-dependent lookup. There is no
31+
"`sqrt-if-needed`" analog to `abs-if-needed`, `conj-if-needed`,
32+
`real-if-needed`, and `imag-if-needed`.</p></li>
33+
</ol>
34+
</li>
35+
<li><p>The overloads that take an initial value parameter `Scalar init`
36+
return `Scalar`.</p>
37+
<ol style="list-style-type: none">
38+
<li><p>2.a. This may silently lose information if the function uses
39+
`std::sqrt` to compute square roots. For example, if `Scalar` and the
40+
input `mdspan`'s `value_type` are both `int`, the square root computed
41+
via `std::sqrt` would return `double`. However, `vector_two_norm` and
42+
`matrix_frob_norm` returning `Scalar` would force a rounding
43+
conversion back to `int`.</p></li>
44+
</ol>
45+
</li>
46+
</ol>
47+
<p>
48+
<b>Suggested fix:</b>
49+
<p/>
50+
The easiest fix for both issues is just to <i>Constrain</i> both `Scalar` and
51+
the input `mdspan`'s `value_type` to be floating-point numbers or
52+
specializations of `std::complex` for these two functions. This
53+
presumes that relaxing this <i>Constraint</i> and fixing the above two issues
54+
later would be a non-breaking change. If that is <em>not</em> the case, then
55+
I would suggest removing the two functions entirely.
56+
</p>
57+
</discussion>
58+
59+
<resolution>
60+
</resolution>
61+
62+
</issue>

0 commit comments

Comments
 (0)