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 var zhemvTestCases = []struct {
24 wantXYNeg []complex128
40 7, 8 + 4i, -9 - 6i, -9 + 3i,
41 znan, -3, -10 - 6i, 0 + 3i,
42 znan, znan, 6, 2 + 8i,
64 wantXNeg: []complex128{
70 wantYNeg: []complex128{
76 wantXYNeg: []complex128{
88 8 - 4i, -3, znan, znan,
89 -9 + 6i, -10 + 6i, 6, znan,
90 -9 - 3i, 0 - 3i, 2 - 8i, -4,
111 wantXNeg: []complex128{
117 wantYNeg: []complex128{
123 wantXYNeg: []complex128{
134 7, 8 + 4i, -9 - 6i, -9 + 3i,
135 znan, -3, -10 - 6i, 0 + 3i,
136 znan, znan, 6, 2 + 8i,
137 znan, znan, znan, -4,
158 wantXNeg: []complex128{
164 wantYNeg: []complex128{
170 wantXYNeg: []complex128{
181 7, 8 + 4i, -9 - 6i, -9 + 3i,
182 znan, -3, -10 - 6i, 0 + 3i,
183 znan, znan, 6, 2 + 8i,
184 znan, znan, znan, -4,
205 wantXNeg: []complex128{
211 wantYNeg: []complex128{
217 wantXYNeg: []complex128{
226 type Zhemver interface {
227 Zhemv(uplo blas.Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
230 func ZhemvTest(t *testing.T, impl Zhemver) {
231 for tc, test := range zhemvTestCases {
233 for _, incX := range []int{-11, -2, -1, 1, 2, 7} {
234 for _, incY := range []int{-11, -2, -1, 1, 2, 7} {
235 for _, lda := range []int{max(1, n), n + 11} {
239 a := makeZGeneral(test.a, n, n, lda)
240 aCopy := make([]complex128, len(a))
243 x := makeZVector(test.x, incX)
244 xCopy := make([]complex128, len(x))
247 y := makeZVector(test.y, incY)
249 impl.Zhemv(test.uplo, n, alpha, a, lda, x, incX, beta, y, incY)
251 if !zsame(x, xCopy) {
252 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected modification of x", tc, incX, incY, lda)
254 if !zsame(a, aCopy) {
255 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected modification of A", tc, incX, incY, lda)
258 var want []complex128
260 case incX > 0 && incY > 0:
261 want = makeZVector(test.want, incY)
262 case incX < 0 && incY > 0:
263 want = makeZVector(test.wantXNeg, incY)
264 case incX > 0 && incY < 0:
265 want = makeZVector(test.wantYNeg, incY)
267 want = makeZVector(test.wantXYNeg, incY)
270 t.Errorf("Case %v (incX=%v,incY=%v,lda=%v): unexpected result\nwant %v\ngot %v", tc, incX, incY, lda, want, y)