lapack/gonum: fix infinite loop in Dlartg with Inf or NaN input
Also, simplify DlartgTest based on Supplemental Material to:
Edward Anderson. 2017. Algorithm 978: Safe Scaling in the Level 1 BLAS.
ACM Trans. Math. Softw. 44, 1, Article 12 (July 2017), 28 pages.
DOI:https://doi.org/10.1145/3061665
MODIFY
lapack/gonum/dlartg.go
lapack/gonum/dlartg.go
@@ -39,7 +39,7 @@ func (impl Implementation) Dlartg(f, g float64) (cs, sn, r float64) {
f1 *= safmn2
g1 *= safmn2
scale = math.Max(math.Abs(f1), math.Abs(g1))
- if scale < safmx2 {
+ if scale < safmx2 || count == 20 {
break
}
}
@@ -56,7 +56,7 @@ func (impl Implementation) Dlartg(f, g float64) (cs, sn, r float64) {
f1 *= safmx2
g1 *= safmx2
scale = math.Max(math.Abs(f1), math.Abs(g1))
- if scale >= safmn2 {
+ if scale >= safmn2 || count == 20 {
break
}
}

lapack/gonum: fix infinite loop in Dlartg with Inf or NaN input

Also, simplify DlartgTest based on Supplemental Material to:

Edward Anderson. 2017. Algorithm 978: Safe Scaling in the Level 1 BLAS.
ACM Trans. Math. Softw. 44, 1, Article 12 (July 2017), 28 pages.
DOI:https://doi.org/10.1145/3061665