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.
10 "gonum.org/v1/gonum/blas"
13 type Zgemver interface {
14 Zgemv(trans blas.Transpose, m, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
17 func ZgemvTest(t *testing.T, impl Zgemver) {
18 for tc, test := range []struct {
29 wantXYNeg []complex128
40 9 + 5i, -2 + 6i, 5 + 1i, 9 + 2i, 10 + 4i,
41 0 - 7i, 9 - 9i, 5 + 3i, -8 - 1i, 7 - 7i,
42 10 - 7i, -1 + 3i, 2 + 2i, 7 + 6i, 9 + 1i,
43 10 + 0i, 8 - 6i, 4 - 6i, -2 - 10i, -5 + 0i,
65 wantXNeg: []complex128{
71 wantYNeg: []complex128{
77 wantXYNeg: []complex128{
88 9 + 5i, -2 + 6i, 5 + 1i, 9 + 2i, 10 + 4i,
89 0 - 7i, 9 - 9i, 5 + 3i, -8 - 1i, 7 - 7i,
90 10 - 7i, -1 + 3i, 2 + 2i, 7 + 6i, 9 + 1i,
91 10 + 0i, 8 - 6i, 4 - 6i, -2 - 10i, -5 + 0i,
114 wantXNeg: []complex128{
121 wantYNeg: []complex128{
128 wantXYNeg: []complex128{
137 trans: blas.ConjTrans,
140 9 + 5i, -2 + 6i, 5 + 1i, 9 + 2i, 10 + 4i,
141 0 - 7i, 9 - 9i, 5 + 3i, -8 - 1i, 7 - 7i,
142 10 - 7i, -1 + 3i, 2 + 2i, 7 + 6i, 9 + 1i,
143 10 + 0i, 8 - 6i, 4 - 6i, -2 - 10i, -5 + 0i,
166 wantXNeg: []complex128{
173 wantYNeg: []complex128{
180 wantXYNeg: []complex128{
189 trans: blas.ConjTrans,
192 9 + 5i, -2 + 6i, 5 + 1i, 9 + 2i, 10 + 4i,
193 0 - 7i, 9 - 9i, 5 + 3i, -8 - 1i, 7 - 7i,
194 10 - 7i, -1 + 3i, 2 + 2i, 7 + 6i, 9 + 1i,
195 10 + 0i, 8 - 6i, 4 - 6i, -2 - 10i, -5 + 0i,
218 wantXNeg: []complex128{
225 wantYNeg: []complex128{
232 wantXYNeg: []complex128{
241 trans: blas.ConjTrans,
244 9 + 5i, -2 + 6i, 5 + 1i, 9 + 2i, 10 + 4i,
245 0 - 7i, 9 - 9i, 5 + 3i, -8 - 1i, 7 - 7i,
246 10 - 7i, -1 + 3i, 2 + 2i, 7 + 6i, 9 + 1i,
247 10 + 0i, 8 - 6i, 4 - 6i, -2 - 10i, -5 + 0i,
270 wantXNeg: []complex128{
277 wantYNeg: []complex128{
284 wantXYNeg: []complex128{
298 case blas.Trans, blas.ConjTrans:
302 for _, incX := range []int{-11, -2, -1, 1, 2, 7} {
303 for _, incY := range []int{-11, -2, -1, 1, 2, 7} {
304 for _, lda := range []int{max(1, n), n + 11} {
307 a := makeZGeneral(test.a, m, n, lda)
308 aCopy := make([]complex128, len(a))
311 x := makeZVector(test.x, incX)
312 xCopy := make([]complex128, len(x))
315 y := makeZVector(test.y, incY)
317 impl.Zgemv(test.trans, m, n, alpha, a, lda, x, incX, test.beta, y, incY)
319 if !zsame(x, xCopy) {
320 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected modification of x", tc, incX, incY, lda)
322 if !zsame(a, aCopy) {
323 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected modification of A", tc, incX, incY, lda)
326 var want []complex128
328 case incX > 0 && incY > 0:
329 want = makeZVector(test.want, incY)
330 case incX < 0 && incY > 0:
331 want = makeZVector(test.wantXNeg, incY)
332 case incX > 0 && incY < 0:
333 want = makeZVector(test.wantYNeg, incY)
335 want = makeZVector(test.wantXYNeg, incY)
338 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected result\nwant %v\ngot %v", tc, incX, incY, lda, want, y)