github.com/gonum/lapack@v0.0.0-20181123203213-e4cdc5a0bff9/testlapack/dgebd2.go (about)

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