diff --git a/lapack/gonum/dtrexc.go b/lapack/gonum/dtrexc.go index d063872a..c577ff9b 100644 --- a/lapack/gonum/dtrexc.go +++ b/lapack/gonum/dtrexc.go @@ -174,12 +174,12 @@ func (impl Implementation) Dtrexc(compq lapack.UpdateSchurComp, n int, t []float here := ifst for here > ilst { // Swap block with next one above. + nbnext := 1 + if here >= 2 && t[(here-1)*ldt+here-2] != 0 { + nbnext = 2 + } if nbf == 1 || nbf == 2 { // Current block either 1×1 or 2×2. - nbnext := 1 - if here-2 >= 0 && t[(here-1)*ldt+here-2] != 0 { - nbnext = 2 - } ok = impl.Dlaexc(wantq, n, t, ldt, q, ldq, here-nbnext, nbnext, nbf, work) if !ok { return ifst, here, false @@ -194,10 +194,6 @@ func (impl Implementation) Dtrexc(compq lapack.UpdateSchurComp, n int, t []float // Current block consists of two 1×1 blocks each of // which must be swapped individually. - nbnext := 1 - if here-2 >= 0 && t[(here-1)*ldt+here-2] != 0 { - nbnext = 2 - } ok = impl.Dlaexc(wantq, n, t, ldt, q, ldq, here-nbnext, nbnext, 1, work) if !ok { return ifst, here, false diff --git a/lapack/testlapack/dtrexc.go b/lapack/testlapack/dtrexc.go index 12c8f895..a5a025c1 100644 --- a/lapack/testlapack/dtrexc.go +++ b/lapack/testlapack/dtrexc.go @@ -175,7 +175,7 @@ func dtrexcTest(t *testing.T, impl Dtrexcer, rnd *rand.Rand, n, ifst, ilst, extr if modMin <= j && j < modMax { continue } - if q.Data[i*q.Stride+j]-qCopy.Data[i*qCopy.Stride+j] != 0 { + if q.Data[i*q.Stride+j] != qCopy.Data[i*qCopy.Stride+j] { t.Errorf("%v: unexpected modification of Q[%v,%v]", name, i, j) } }