github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/blas/testblas/zgerc.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 11 type Zgercer interface { 12 Zgerc(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) 13 } 14 15 func ZgercTest(t *testing.T, impl Zgercer) { 16 for tc, test := range []struct { 17 alpha complex128 18 x []complex128 19 incX int 20 y []complex128 21 incY int 22 a []complex128 23 24 want []complex128 25 }{ 26 { 27 incX: 1, 28 incY: 1, 29 alpha: 1 + 2i, 30 }, 31 { 32 incX: 1, 33 incY: 1, 34 alpha: 1 + 2i, 35 x: []complex128{1 + 13i, 18 + 15i, 10 + 18i}, 36 y: []complex128{15 + 12i, 4 + 8i, 5 + 16i, 19 + 12i}, 37 a: []complex128{ 38 10 + 9i, 6 + 17i, 3 + 10i, 6 + 7i, 39 3 + 4i, 11 + 16i, 5 + 14i, 11 + 18i, 40 18 + 6i, 4 + 1i, 13 + 2i, 14 + 3i}, 41 want: []complex128{ 42 -185 + 534i, 26 + 277i, 118 + 485i, -289 + 592i, 43 435 + 913i, 371 + 316i, 761 + 461i, 395 + 1131i, 44 84 + 888i, 204 + 361i, 491 + 608i, -24 + 1037i}, 45 }, 46 { 47 incX: 7, 48 incY: 13, 49 alpha: 1 + 2i, 50 x: []complex128{1 + 13i, 18 + 15i, 10 + 18i}, 51 y: []complex128{15 + 12i, 4 + 8i, 5 + 16i, 19 + 12i}, 52 a: []complex128{ 53 10 + 9i, 6 + 17i, 3 + 10i, 6 + 7i, 54 3 + 4i, 11 + 16i, 5 + 14i, 11 + 18i, 55 18 + 6i, 4 + 1i, 13 + 2i, 14 + 3i}, 56 want: []complex128{ 57 -185 + 534i, 26 + 277i, 118 + 485i, -289 + 592i, 58 435 + 913i, 371 + 316i, 761 + 461i, 395 + 1131i, 59 84 + 888i, 204 + 361i, 491 + 608i, -24 + 1037i}, 60 }, 61 { 62 incX: -7, 63 incY: -13, 64 alpha: 1 + 2i, 65 x: []complex128{10 + 18i, 18 + 15i, 1 + 13i}, 66 y: []complex128{19 + 12i, 5 + 16i, 4 + 8i, 15 + 12i}, 67 a: []complex128{ 68 10 + 9i, 6 + 17i, 3 + 10i, 6 + 7i, 69 3 + 4i, 11 + 16i, 5 + 14i, 11 + 18i, 70 18 + 6i, 4 + 1i, 13 + 2i, 14 + 3i}, 71 want: []complex128{ 72 -185 + 534i, 26 + 277i, 118 + 485i, -289 + 592i, 73 435 + 913i, 371 + 316i, 761 + 461i, 395 + 1131i, 74 84 + 888i, 204 + 361i, 491 + 608i, -24 + 1037i}, 75 }, 76 { 77 incX: 1, 78 incY: 1, 79 alpha: 1 + 2i, 80 x: []complex128{5 + 16i, 12 + 19i, 9 + 7i, 2 + 4i}, 81 y: []complex128{18 + 7i, 20 + 15i, 12 + 14i}, 82 a: []complex128{ 83 11 + 4i, 17 + 18i, 7 + 13i, 84 14 + 20i, 14 + 10i, 7 + 5i, 85 7 + 17i, 10 + 6i, 11 + 13i, 86 7 + 6i, 19 + 16i, 8 + 8i, 87 }, 88 want: []complex128{ 89 -293 + 661i, -133 + 943i, 47 + 703i, 90 -153 + 976i, 139 + 1260i, 297 + 885i, 91 92 + 502i, 285 + 581i, 301 + 383i, 92 -45 + 192i, 19 + 266i, 48 + 188i, 93 }, 94 }, 95 { 96 incX: 7, 97 incY: 13, 98 alpha: 1 + 2i, 99 x: []complex128{5 + 16i, 12 + 19i, 9 + 7i, 2 + 4i}, 100 y: []complex128{18 + 7i, 20 + 15i, 12 + 14i}, 101 a: []complex128{ 102 11 + 4i, 17 + 18i, 7 + 13i, 103 14 + 20i, 14 + 10i, 7 + 5i, 104 7 + 17i, 10 + 6i, 11 + 13i, 105 7 + 6i, 19 + 16i, 8 + 8i, 106 }, 107 want: []complex128{ 108 -293 + 661i, -133 + 943i, 47 + 703i, 109 -153 + 976i, 139 + 1260i, 297 + 885i, 110 92 + 502i, 285 + 581i, 301 + 383i, 111 -45 + 192i, 19 + 266i, 48 + 188i, 112 }, 113 }, 114 { 115 incX: -7, 116 incY: -13, 117 alpha: 1 + 2i, 118 x: []complex128{2 + 4i, 9 + 7i, 12 + 19i, 5 + 16i}, 119 y: []complex128{12 + 14i, 20 + 15i, 18 + 7i}, 120 a: []complex128{ 121 11 + 4i, 17 + 18i, 7 + 13i, 122 14 + 20i, 14 + 10i, 7 + 5i, 123 7 + 17i, 10 + 6i, 11 + 13i, 124 7 + 6i, 19 + 16i, 8 + 8i, 125 }, 126 want: []complex128{ 127 -293 + 661i, -133 + 943i, 47 + 703i, 128 -153 + 976i, 139 + 1260i, 297 + 885i, 129 92 + 502i, 285 + 581i, 301 + 383i, 130 -45 + 192i, 19 + 266i, 48 + 188i, 131 }, 132 }, 133 { 134 incX: -7, 135 incY: -13, 136 alpha: 0, 137 x: []complex128{2 + 4i, 9 + 7i, 12 + 19i, 5 + 16i}, 138 y: []complex128{12 + 14i, 20 + 15i, 18 + 7i}, 139 a: []complex128{ 140 11 + 4i, 17 + 18i, 7 + 13i, 141 14 + 20i, 14 + 10i, 7 + 5i, 142 7 + 17i, 10 + 6i, 11 + 13i, 143 7 + 6i, 19 + 16i, 8 + 8i, 144 }, 145 want: []complex128{ 146 11 + 4i, 17 + 18i, 7 + 13i, 147 14 + 20i, 14 + 10i, 7 + 5i, 148 7 + 17i, 10 + 6i, 11 + 13i, 149 7 + 6i, 19 + 16i, 8 + 8i, 150 }, 151 }, 152 } { 153 m := len(test.x) 154 n := len(test.y) 155 incX := test.incX 156 incY := test.incY 157 158 for _, lda := range []int{max(1, n), n + 20} { 159 x := makeZVector(test.x, incX) 160 xCopy := make([]complex128, len(x)) 161 copy(xCopy, x) 162 163 y := makeZVector(test.y, incY) 164 yCopy := make([]complex128, len(y)) 165 copy(yCopy, y) 166 167 a := makeZGeneral(test.a, m, n, lda) 168 want := makeZGeneral(test.want, m, n, lda) 169 170 impl.Zgerc(m, n, test.alpha, x, incX, y, incY, a, lda) 171 172 if !zsame(x, xCopy) { 173 t.Errorf("Case %v: unexpected modification of x", tc) 174 } 175 if !zsame(y, yCopy) { 176 t.Errorf("Case %v: unexpected modification of y", tc) 177 } 178 if !zsame(want, a) { 179 t.Errorf("Case %v: unexpected result\nwant %v\ngot %v", tc, want, a) 180 } 181 } 182 } 183 }