blas/testblas: move test cases for Ztrmv to package-level variable
MODIFY
blas/testblas/ztrmv.go
blas/testblas/ztrmv.go
@@ -11,13 +11,7 @@ import (
"gonum.org/v1/gonum/blas"
)
-type Ztrmver interface {
- Ztrmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex128, lda int, x []complex128, incX int)
-}
-
-func ZtrmvTest(t *testing.T, impl Ztrmver) {
- nan := cmplx.NaN()
- for tc, test := range []struct {
+var ztrmvTestCases = []struct {
uplo blas.Uplo
a []complex128
x []complex128
@@ -44,9 +38,9 @@ func ZtrmvTest(t *testing.T, impl Ztrmver) {
uplo: blas.Upper,
a: []complex128{
6 - 8i, -10 + 10i, -6 - 3i, -1 - 8i,
- nan, 7 + 8i, -7 + 9i, 3 + 6i,
- nan, nan, 6 - 4i, -2 - 5i,
- nan, nan, nan, 4 - 8i,
+ 0, 7 + 8i, -7 + 9i, 3 + 6i,
+ 0, 0, 6 - 4i, -2 - 5i,
+ 0, 0, 0, 4 - 8i,
},
x: []complex128{
10 - 5i,
@@ -132,9 +126,9 @@ func ZtrmvTest(t *testing.T, impl Ztrmver) {
{
uplo: blas.Lower,
a: []complex128{
- 10 - 8i, nan, nan, nan,
- 1 - 6i, -4 + 8i, nan, nan,
- 2 - 6i, 4 - 8i, 5 + 3i, nan,
+ 10 - 8i, 0, 0, 0,
+ 1 - 6i, -4 + 8i, 0, 0,
+ 2 - 6i, 4 - 8i, 5 + 3i, 0,
-7 - 4i, 1 + 3i, -2 - 4i, 9 + 8i,
},
x: []complex128{
@@ -218,7 +212,15 @@ func ZtrmvTest(t *testing.T, impl Ztrmver) {
-92 - 8i,
},
},
- } {
+}
+
+type Ztrmver interface {
+ Ztrmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex128, lda int, x []complex128, incX int)
+}
+
+func ZtrmvTest(t *testing.T, impl Ztrmver) {
+ nan := cmplx.NaN()
+ for tc, test := range ztrmvTestCases {
n := len(test.x)
uplo := test.uplo
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans, blas.ConjTrans} {
@@ -226,6 +228,19 @@ func ZtrmvTest(t *testing.T, impl Ztrmver) {
for _, incX := range []int{-11, -2, -1, 1, 2, 7} {
for _, lda := range []int{max(1, n), n + 11} {
a := makeZGeneral(test.a, n, n, lda)
+ if uplo == blas.Upper {
+ for i := 0; i < n; i++ {
+ for j := 0; j < i; j++ {
+ a[i*lda+j] = nan
+ }
+ }
+ } else {
+ for i := 0; i < n; i++ {
+ for j := i + 1; j < n; j++ {
+ a[i*lda+j] = nan
+ }
+ }
+ }
if diag == blas.Unit {
for i := 0; i < n; i++ {
a[i*lda+i] = nan

blas/testblas: move test cases for Ztrmv to package-level variable