github.com/gopherd/gonum@v0.0.4/blas/testblas/zhpr2.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 "github.com/gopherd/gonum/blas" 11 ) 12 13 type Zhpr2er interface { 14 Zhpr2(uplo blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, ap []complex128) 15 } 16 17 func Zhpr2Test(t *testing.T, impl Zhpr2er) { 18 for tc, test := range zher2TestCases { 19 n := len(test.x) 20 incX := test.incX 21 incY := test.incY 22 for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} { 23 x := makeZVector(test.x, incX) 24 xCopy := make([]complex128, len(x)) 25 copy(xCopy, x) 26 27 y := makeZVector(test.y, incY) 28 yCopy := make([]complex128, len(y)) 29 copy(yCopy, y) 30 31 ap := zPack(uplo, n, test.a, n) 32 impl.Zhpr2(uplo, n, test.alpha, x, incX, y, incY, ap) 33 a := zUnpackAsHermitian(uplo, n, ap) 34 35 if !zsame(x, xCopy) { 36 t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected modification of x", tc, uplo, incX, incY) 37 } 38 if !zsame(y, yCopy) { 39 t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected modification of y", tc, uplo, incX, incY) 40 } 41 if !zsame(test.want, a) { 42 t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected result\nwant: %v\ngot: %v", tc, uplo, incX, incY, test.want, a) 43 } 44 } 45 } 46 }