OSDN Git Service

new repo
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / lapack / testlapack / dgebd2.go
1 // Copyright ©2015 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
13 type Dgebd2er interface {
14         Dgebd2(m, n int, a []float64, lda int, d, e, tauq, taup, work []float64)
15 }
16
17 func Dgebd2Test(t *testing.T, impl Dgebd2er) {
18         rnd := rand.New(rand.NewSource(1))
19         for _, test := range []struct {
20                 m, n, lda int
21         }{
22                 {3, 4, 0},
23                 {4, 3, 0},
24                 {3, 4, 10},
25                 {4, 3, 10},
26         } {
27                 m := test.m
28                 n := test.n
29                 lda := test.lda
30                 if lda == 0 {
31                         lda = n
32                 }
33                 nb := min(m, n) // 'nb' name parallel with Dlabrd code.
34                 a := make([]float64, m*lda)
35                 for i := range a {
36                         a[i] = rnd.NormFloat64()
37                 }
38                 d := nanSlice(nb)
39                 e := nanSlice(nb - 1)
40                 tauP := nanSlice(nb)
41                 tauQ := nanSlice(nb)
42                 work := nanSlice(max(m, n))
43                 aCopy := make([]float64, len(a))
44                 copy(aCopy, a)
45                 impl.Dgebd2(m, n, a, lda, d, e, tauQ, tauP, work)
46                 if m >= n && nb == n {
47                         tauP[n-1] = 0
48                 }
49                 if m < n && nb == m {
50                         tauQ[m-1] = 0
51                 }
52
53                 checkBidiagonal(t, m, n, nb, a, lda, d, e, tauP, tauQ, aCopy)
54         }
55 }