gonum.org/v1/gonum@v0.14.0/lapack/testlapack/dgeev_bench.go (about) 1 // Copyright ©2016 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 testlapack 6 7 import ( 8 "testing" 9 10 "golang.org/x/exp/rand" 11 12 "gonum.org/v1/gonum/blas/blas64" 13 "gonum.org/v1/gonum/lapack" 14 ) 15 16 func DgeevBenchmark(b *testing.B, impl Dgeever) { 17 var resultGeneral blas64.General 18 rnd := rand.New(rand.NewSource(1)) 19 benchmarks := []struct { 20 name string 21 a blas64.General 22 }{ 23 {"AntisymRandom3", NewAntisymRandom(3, rnd).Matrix()}, 24 {"AntisymRandom4", NewAntisymRandom(4, rnd).Matrix()}, 25 {"AntisymRandom5", NewAntisymRandom(5, rnd).Matrix()}, 26 {"AntisymRandom10", NewAntisymRandom(10, rnd).Matrix()}, 27 {"AntisymRandom50", NewAntisymRandom(50, rnd).Matrix()}, 28 {"AntisymRandom100", NewAntisymRandom(100, rnd).Matrix()}, 29 {"AntisymRandom200", NewAntisymRandom(200, rnd).Matrix()}, 30 {"AntisymRandom500", NewAntisymRandom(500, rnd).Matrix()}, 31 {"Circulant3", Circulant(3).Matrix()}, 32 {"Circulant4", Circulant(4).Matrix()}, 33 {"Circulant5", Circulant(5).Matrix()}, 34 {"Circulant10", Circulant(10).Matrix()}, 35 {"Circulant50", Circulant(50).Matrix()}, 36 {"Circulant100", Circulant(100).Matrix()}, 37 {"Circulant200", Circulant(200).Matrix()}, 38 {"Circulant500", Circulant(500).Matrix()}, 39 } 40 for _, bm := range benchmarks { 41 n := bm.a.Rows 42 a := zeros(n, n, n) 43 vl := zeros(n, n, n) 44 vr := zeros(n, n, n) 45 wr := make([]float64, n) 46 wi := make([]float64, n) 47 work := make([]float64, 1) 48 impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, a.Data, a.Stride, wr, wi, vl.Data, vl.Stride, vr.Data, vr.Stride, work, -1) 49 work = make([]float64, int(work[0])) 50 b.Run(bm.name, func(b *testing.B) { 51 for i := 0; i < b.N; i++ { 52 b.StopTimer() 53 copyGeneral(a, bm.a) 54 b.StartTimer() 55 impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, a.Data, a.Stride, wr, wi, 56 vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work)) 57 } 58 resultGeneral = a 59 }) 60 } 61 if resultGeneral.Data == nil { 62 b.Error("unexpected nil data") 63 } 64 }