gonum.org/v1/gonum@v0.14.0/blas/testblas/zhpmv.go (about) 1 // Copyright ©2017 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package testblas 6 7 import ( 8 "testing" 9 10 "gonum.org/v1/gonum/blas" 11 ) 12 13 type Zhpmver interface { 14 Zhpmv(uplo blas.Uplo, n int, alpha complex128, ap []complex128, x []complex128, incX int, beta complex128, y []complex128, incY int) 15 } 16 17 func ZhpmvTest(t *testing.T, impl Zhpmver) { 18 for tc, test := range zhemvTestCases { 19 uplo := test.uplo 20 n := len(test.x) 21 alpha := test.alpha 22 beta := test.beta 23 for _, incX := range []int{-11, -2, -1, 1, 2, 7} { 24 for _, incY := range []int{-11, -2, -1, 1, 2, 7} { 25 x := makeZVector(test.x, incX) 26 xCopy := make([]complex128, len(x)) 27 copy(xCopy, x) 28 29 y := makeZVector(test.y, incY) 30 31 ap := zPack(uplo, n, test.a, n) 32 apCopy := make([]complex128, len(ap)) 33 copy(apCopy, ap) 34 35 impl.Zhpmv(test.uplo, n, alpha, ap, x, incX, beta, y, incY) 36 37 if !zsame(x, xCopy) { 38 t.Errorf("Case %v (incX=%v,incY=%v): unexpected modification of x", tc, incX, incY) 39 } 40 if !zsame(ap, apCopy) { 41 t.Errorf("Case %v (incX=%v,incY=%v): unexpected modification of A", tc, incX, incY) 42 } 43 44 var want []complex128 45 switch { 46 case incX > 0 && incY > 0: 47 want = makeZVector(test.want, incY) 48 case incX < 0 && incY > 0: 49 want = makeZVector(test.wantXNeg, incY) 50 case incX > 0 && incY < 0: 51 want = makeZVector(test.wantYNeg, incY) 52 default: 53 want = makeZVector(test.wantXYNeg, incY) 54 } 55 if !zsame(y, want) { 56 t.Errorf("Case %v (incX=%v,incY=%v): unexpected result\nwant %v\ngot %v", tc, incX, incY, want, y) 57 } 58 } 59 } 60 } 61 }