testlapack: fix work slice length in DormbrTest
@@ -25,6 +25,7 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
for _, side := range []blas.Side{blas.Left, blas.Right} {
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
+ for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} {
for _, test := range []struct {
m, n, k, lda, ldc int
}{
@@ -50,8 +51,10 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
ldc = n
}
nq := n
+ nw := m
if side == blas.Left {
nq = m
+ nw = n
}
// Compute a decomposition.
@@ -77,23 +80,35 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
tauQ := make([]float64, nTau)
d := make([]float64, nTau)
e := make([]float64, nTau)
- lwork := -1
+
work := make([]float64, 1)
- impl.Dgebrd(ma, na, a, lda, d, e, tauQ, tauP, work, lwork)
+ impl.Dgebrd(ma, na, a, lda, d, e, tauQ, tauP, work, -1)
work = make([]float64, int(work[0]))
- lwork = len(work)
-
- impl.Dgebrd(ma, na, a, lda, d, e, tauQ, tauP, work, lwork)
+ impl.Dgebrd(ma, na, a, lda, d, e, tauQ, tauP, work, len(work))
// Apply and compare update.
c := make([]float64, m*ldc)
for i := range c {
c[i] = rnd.NormFloat64()
}
-
cCopy := make([]float64, len(c))
copy(cCopy, c)
+ var lwork int
+ switch wl {
+ case minimumWork:
+ lwork = nw
+ case optimumWork:
+ impl.Dormbr(vect, side, trans, m, n, k, a, lda, tauQ, c, ldc, work, -1)
+ lwork = int(work[0])
+ case mediumWork:
+ work := make([]float64, 1)
+ impl.Dormbr(vect, side, trans, m, n, k, a, lda, tauQ, c, ldc, work, -1)
+ lwork = (int(work[0]) + nw) / 2
+ }
+ lwork = max(1, lwork)
+ work = make([]float64, lwork)
+
if vect == lapack.ApplyQ {
impl.Dormbr(vect, side, trans, m, n, k, a, lda, tauQ, c, ldc, work, lwork)
} else {
@@ -144,3 +159,4 @@ func DormbrTest(t *testing.T, impl Dormbrer) {
}
}
}
+}
