File: zhpr2.go

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (46 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright ©2017 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package testblas

import (
	"testing"

	"gonum.org/v1/gonum/blas"
)

type Zhpr2er interface {
	Zhpr2(uplo blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, ap []complex128)
}

func Zhpr2Test(t *testing.T, impl Zhpr2er) {
	for tc, test := range zher2TestCases {
		n := len(test.x)
		incX := test.incX
		incY := test.incY
		for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
			x := makeZVector(test.x, incX)
			xCopy := make([]complex128, len(x))
			copy(xCopy, x)

			y := makeZVector(test.y, incY)
			yCopy := make([]complex128, len(y))
			copy(yCopy, y)

			ap := zPack(uplo, n, test.a, n)
			impl.Zhpr2(uplo, n, test.alpha, x, incX, y, incY, ap)
			a := zUnpackAsHermitian(uplo, n, ap)

			if !zsame(x, xCopy) {
				t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected modification of x", tc, uplo, incX, incY)
			}
			if !zsame(y, yCopy) {
				t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected modification of y", tc, uplo, incX, incY)
			}
			if !zsame(test.want, a) {
				t.Errorf("Case %v (uplo=%v,incX=%v,incY=%v): unexpected result\nwant: %v\ngot:  %v", tc, uplo, incX, incY, test.want, a)
			}
		}
	}
}