diff --git a/testlapack/dlahqr.go b/testlapack/dlahqr.go index caff2be1..6b0c8fc2 100644 --- a/testlapack/dlahqr.go +++ b/testlapack/dlahqr.go @@ -312,11 +312,11 @@ func testDlahqr(t *testing.T, impl Dlahqrer, test dlahqrTest) { } } - // Check that wr and wi have not been modified outside [start:ihi+1]. - if !isAllNaN(wr[:start]) || !isAllNaN(wr[ihi+1:]) { + // Check that wr and wi have not been modified in [:start]. + if !isAllNaN(wr[:start]) { t.Errorf("%v: unexpected modification of wr", prefix) } - if !isAllNaN(wi[:start]) || !isAllNaN(wi[ihi+1:]) { + if !isAllNaN(wi[:start]) { t.Errorf("%v: unexpected modification of wi", prefix) } @@ -360,7 +360,7 @@ func testDlahqr(t *testing.T, impl Dlahqrer, test dlahqrTest) { // The second imaginary part must be negative with the same // magnitude. if wi[i] != -wi[i+1] { - t.Errorf("%v: wi[%v] != wi[%v]", prefix, i, i+1) + t.Errorf("%v: wi[%v] != -wi[%v]", prefix, i, i+1) } if wantt { // Check that wi[i] has the correct value. @@ -402,8 +402,8 @@ func testDlahqr(t *testing.T, impl Dlahqrer, test dlahqrTest) { if test.evWant != nil { for i := start; i <= ihi; i++ { ev := complex(wr[i], wi[i]) - if !containsComplex(test.evWant, ev, tol) { - t.Log(test.evWant, ev) + found, _ := containsComplex(test.evWant, ev, tol) + if !found { t.Errorf("%v: unexpected eigenvalue %v", prefix, ev) } } diff --git a/testlapack/dlaqr04.go b/testlapack/dlaqr04.go index 641efe97..6c3304ee 100644 --- a/testlapack/dlaqr04.go +++ b/testlapack/dlaqr04.go @@ -403,8 +403,8 @@ func testDlaqr04(t *testing.T, impl Dlaqr04er, test dlaqr04Test, optwork bool, r if test.evWant != nil { for i := start; i <= ihi; i++ { ev := complex(wr[i], wi[i]) - if !containsComplex(test.evWant, ev, tol) { - t.Log(test.evWant, ev) + found, _ := containsComplex(test.evWant, ev, tol) + if !found { t.Errorf("%v: unexpected eigenvalue %v", prefix, ev) } } diff --git a/testlapack/dlaqr23.go b/testlapack/dlaqr23.go index e285c3b9..26bdb97e 100644 --- a/testlapack/dlaqr23.go +++ b/testlapack/dlaqr23.go @@ -295,7 +295,8 @@ func testDlaqr23(t *testing.T, impl Dlaqr23er, test dlaqr23Test, opt bool, recur if test.evWant != nil { for i := kbot - nd + 1; i <= kbot; i++ { ev := complex(sr[i], si[i]) - if !containsComplex(test.evWant, ev, tol) { + found, _ := containsComplex(test.evWant, ev, tol) + if !found { t.Errorf("%v: unexpected eigenvalue %v", prefix, ev) } } diff --git a/testlapack/general.go b/testlapack/general.go index 94a28e95..34ce3dbf 100644 --- a/testlapack/general.go +++ b/testlapack/general.go @@ -972,14 +972,14 @@ func schurBlockSize(t blas64.General, i int) (size int, first bool) { } // containsComplex returns whether z is approximately equal to one of the complex -// numbers in v. -func containsComplex(v []complex128, z complex128, tol float64) bool { +// numbers in v. If z is found, its index in v will be also returned. +func containsComplex(v []complex128, z complex128, tol float64) (found bool, index int) { for i := range v { if cmplx.Abs(v[i]-z) < tol { - return true + return true, i } } - return false + return false, -1 } // isAllNaN returns whether x contains only NaN values.