lapack/testlapack: use const tol in DlarfgTest
MODIFY
lapack/testlapack/dlarfg.go
lapack/testlapack/dlarfg.go
@@ -12,6 +12,7 @@ import (
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
+ "gonum.org/v1/gonum/floats"
)
type Dlarfger interface {
@@ -19,6 +20,7 @@ type Dlarfger interface {
}
func DlarfgTest(t *testing.T, impl Dlarfger) {
+ const tol = 1e-14
rnd := rand.New(rand.NewSource(1))
for i, test := range []struct {
alpha float64
@@ -105,7 +107,7 @@ func DlarfgTest(t *testing.T, impl Dlarfger) {
}
blas64.Gemm(blas.Trans, blas.NoTrans, 1, hmat, hmat, 0, eye)
dist := distFromIdentity(n, eye.Data, n)
- if dist > 1e-14 {
+ if dist > tol {
t.Errorf("H^T * H is not close to I, dist=%v", dist)
}
@@ -122,14 +124,11 @@ func DlarfgTest(t *testing.T, impl Dlarfger) {
Data: ans,
}
blas64.Gemv(blas.NoTrans, 1, hmat, xVec, 0, ansVec)
- if math.Abs(ans[0]-beta) > 1e-14 {
+ if math.Abs(ans[0]-beta) > tol {
t.Errorf("Case %v, beta mismatch. Want %v, got %v", i, ans[0], beta)
}
- for i := 1; i < n; i++ {
- if math.Abs(ans[i]) > 1e-14 {
- t.Errorf("Case %v, nonzero answer %v", i, ans)
- break
- }
+ if floats.Norm(ans[1:n], math.Inf(1)) > tol {
+ t.Errorf("Case %v, nonzero answer %v", i, ans[1:n])
}
}
}

lapack/testlapack: use const tol in DlarfgTest