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.
11 "golang.org/x/exp/rand"
13 "gonum.org/v1/gonum/blas"
16 var benchSinkZ []complex128
18 func BenchmarkZher(b *testing.B) {
19 for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower} {
20 for _, n := range []int{10, 100, 1000, 10000} {
21 for _, inc := range []int{1, 10, 1000} {
22 benchmarkZher(b, uplo, n, inc)
28 func benchmarkZher(b *testing.B, uplo blas.Uplo, n, inc int) {
29 b.Run(fmt.Sprintf("Uplo%d-N%d-Inc%d", uplo, n, inc), func(b *testing.B) {
30 rnd := rand.New(rand.NewSource(1))
31 alpha := rnd.NormFloat64()
32 x := make([]complex128, (n-1)*inc+1)
34 x[i] = complex(rnd.NormFloat64(), rnd.NormFloat64())
36 a := make([]complex128, len(benchSinkZ))
38 a[i] = complex(rnd.NormFloat64(), rnd.NormFloat64())
40 benchSinkZ = make([]complex128, n*n)
43 for i := 0; i < b.N; i++ {
44 impl.Zher(uplo, n, alpha, x, inc, benchSinkZ, n)