mirror of
https://github.com/gonum/gonum.git
synced 2025-10-16 20:20:41 +08:00
blas/testblas: move test cases for Zhemv to package-level variable
This commit is contained in:

committed by
Vladimír Chalupecký

parent
2f7ca94df6
commit
f5b94da74f
@@ -11,13 +11,7 @@ import (
|
||||
"gonum.org/v1/gonum/blas"
|
||||
)
|
||||
|
||||
type Zhemver interface {
|
||||
Zhemv(uplo blas.Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
|
||||
}
|
||||
|
||||
func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
nan := cmplx.NaN()
|
||||
for tc, test := range []struct {
|
||||
var zhemvTestCases = []struct {
|
||||
uplo blas.Uplo
|
||||
alpha complex128
|
||||
a []complex128
|
||||
@@ -29,7 +23,7 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
wantXNeg []complex128
|
||||
wantYNeg []complex128
|
||||
wantXYNeg []complex128
|
||||
}{
|
||||
}{
|
||||
{
|
||||
uplo: blas.Upper,
|
||||
alpha: 6 + 2i,
|
||||
@@ -45,9 +39,9 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
alpha: 6 + 2i,
|
||||
a: []complex128{
|
||||
7, 8 + 4i, -9 - 6i, -9 + 3i,
|
||||
nan, -3, -10 - 6i, 0 + 3i,
|
||||
nan, nan, 6, 2 + 8i,
|
||||
nan, nan, nan, -4,
|
||||
0, -3, -10 - 6i, 0 + 3i,
|
||||
0, 0, 6, 2 + 8i,
|
||||
0, 0, 0, -4,
|
||||
},
|
||||
x: []complex128{
|
||||
-4 + 0i,
|
||||
@@ -91,9 +85,9 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
uplo: blas.Lower,
|
||||
alpha: 6 + 2i,
|
||||
a: []complex128{
|
||||
7, nan, nan, nan,
|
||||
8 - 4i, -3, nan, nan,
|
||||
-9 + 6i, -10 + 6i, 6, nan,
|
||||
7, 0, 0, 0,
|
||||
8 - 4i, -3, 0, 0,
|
||||
-9 + 6i, -10 + 6i, 6, 0,
|
||||
-9 - 3i, 0 - 3i, 2 - 8i, -4,
|
||||
},
|
||||
x: []complex128{
|
||||
@@ -139,9 +133,9 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
alpha: 0,
|
||||
a: []complex128{
|
||||
7, 8 + 4i, -9 - 6i, -9 + 3i,
|
||||
nan, -3, -10 - 6i, 0 + 3i,
|
||||
nan, nan, 6, 2 + 8i,
|
||||
nan, nan, nan, -4,
|
||||
0, -3, -10 - 6i, 0 + 3i,
|
||||
0, 0, 6, 2 + 8i,
|
||||
0, 0, 0, -4,
|
||||
},
|
||||
x: []complex128{
|
||||
-4 + 0i,
|
||||
@@ -186,9 +180,9 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
alpha: 6 + 2i,
|
||||
a: []complex128{
|
||||
7, 8 + 4i, -9 - 6i, -9 + 3i,
|
||||
nan, -3, -10 - 6i, 0 + 3i,
|
||||
nan, nan, 6, 2 + 8i,
|
||||
nan, nan, nan, -4,
|
||||
0, -3, -10 - 6i, 0 + 3i,
|
||||
0, 0, 6, 2 + 8i,
|
||||
0, 0, 0, -4,
|
||||
},
|
||||
x: []complex128{
|
||||
-4 + 0i,
|
||||
@@ -228,7 +222,15 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
640 + 680i,
|
||||
},
|
||||
},
|
||||
} {
|
||||
}
|
||||
|
||||
type Zhemver interface {
|
||||
Zhemv(uplo blas.Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
|
||||
}
|
||||
|
||||
func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
nan := cmplx.NaN()
|
||||
for tc, test := range zhemvTestCases {
|
||||
n := len(test.x)
|
||||
for _, incX := range []int{-11, -2, -1, 1, 2, 7} {
|
||||
for _, incY := range []int{-11, -2, -1, 1, 2, 7} {
|
||||
@@ -238,6 +240,19 @@ func ZhemvTest(t *testing.T, impl Zhemver) {
|
||||
beta := test.beta
|
||||
|
||||
a := makeZGeneral(test.a, n, n, lda)
|
||||
if test.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
|
||||
}
|
||||
}
|
||||
}
|
||||
aCopy := make([]complex128, len(a))
|
||||
copy(aCopy, a)
|
||||
|
||||
|
Reference in New Issue
Block a user