testlapack: test Dorgtr with minimum and medium work
package testlapack
import (
- "math"
"math/rand"
"testing"
@@ -22,13 +21,20 @@ type Dorgtrer interface {
func DorgtrTest(t *testing.T, impl Dorgtrer) {
rnd := rand.New(rand.NewSource(1))
for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
+ for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} {
for _, test := range []struct {
n, lda int
}{
+ {1, 0},
+ {2, 0},
+ {3, 0},
{6, 0},
{33, 0},
{100, 0},
+ {1, 3},
+ {2, 5},
+ {3, 7},
{6, 10},
{33, 50},
{100, 120},
@@ -53,11 +59,22 @@ func DorgtrTest(t *testing.T, impl Dorgtrer) {
work = make([]float64, int(work[0]))
impl.Dsytrd(uplo, n, a, lda, d, e, tau, work, len(work))
+ var lwork int
+ switch wl {
+ case minimumWork:
+ lwork = max(1, n-1)
+ case mediumWork:
+ work := make([]float64, 1)
impl.Dorgtr(uplo, n, a, lda, tau, work, -1)
- work = make([]float64, int(work[0]))
- for i := range work {
- work[i] = math.NaN()
+ lwork = (int(work[0]) + n - 1) / 2
+ lwork = max(1, lwork)
+ case optimumWork:
+ work := make([]float64, 1)
+ impl.Dorgtr(uplo, n, a, lda, tau, work, -1)
+ lwork = int(work[0])
}
+ work = nanSlice(lwork)
+
impl.Dorgtr(uplo, n, a, lda, tau, work, len(work))
q := blas64.General{
@@ -110,9 +127,10 @@ func DorgtrTest(t *testing.T, impl Dorgtrer) {
ans := blas64.General{Rows: n, Cols: n, Stride: n, Data: make([]float64, n*n)}
blas64.Gemm(blas.Trans, blas.NoTrans, 1, q, tmp, 0, ans)
- if !floats.EqualApprox(ans.Data, tri.Data, 1e-8) {
+ if !floats.EqualApprox(ans.Data, tri.Data, 1e-13) {
t.Errorf("Recombination mismatch. n = %v, isUpper = %v", n, uplo == blas.Upper)
}
}
}
}
+}
