gonum.org/v1/gonum@v0.14.0/lapack/testlapack/dlabrd.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"
     9  	"testing"
    10  
    11  	"golang.org/x/exp/rand"
    12  )
    13  
    14  type Dlabrder interface {
    15  	Dlabrd(m, n, nb int, a []float64, lda int, d, e, tauq, taup, x []float64, ldx int, y []float64, ldy int)
    16  }
    17  
    18  func DlabrdTest(t *testing.T, impl Dlabrder) {
    19  	rnd := rand.New(rand.NewSource(1))
    20  	for _, test := range []struct {
    21  		m, n, nb, lda, ldx, ldy int
    22  	}{
    23  		{4, 5, 2, 0, 0, 0},
    24  		{4, 5, 4, 0, 0, 0},
    25  		{5, 5, 2, 0, 0, 0},
    26  		{5, 5, 5, 0, 0, 0},
    27  		{5, 4, 4, 0, 0, 0},
    28  		{5, 4, 4, 0, 0, 0},
    29  
    30  		{4, 5, 2, 10, 11, 12},
    31  		{4, 5, 4, 10, 11, 12},
    32  		{5, 5, 2, 10, 11, 12},
    33  		{5, 5, 5, 10, 11, 12},
    34  		{5, 4, 2, 10, 11, 12},
    35  		{5, 4, 4, 10, 11, 12},
    36  
    37  		{4, 5, 2, 11, 12, 10},
    38  		{4, 5, 4, 11, 12, 10},
    39  		{5, 5, 2, 11, 12, 10},
    40  		{5, 5, 5, 11, 12, 10},
    41  		{5, 4, 2, 11, 12, 10},
    42  		{5, 4, 4, 11, 12, 10},
    43  
    44  		{4, 5, 2, 12, 11, 10},
    45  		{4, 5, 4, 12, 11, 10},
    46  		{5, 5, 2, 12, 11, 10},
    47  		{5, 5, 5, 12, 11, 10},
    48  		{5, 4, 2, 12, 11, 10},
    49  		{5, 4, 4, 12, 11, 10},
    50  	} {
    51  		m := test.m
    52  		n := test.n
    53  		nb := test.nb
    54  		lda := test.lda
    55  		if lda == 0 {
    56  			lda = n
    57  		}
    58  		ldy := test.ldy
    59  		if ldy == 0 {
    60  			ldy = nb
    61  		}
    62  		ldx := test.ldx
    63  		if ldx == 0 {
    64  			ldx = nb
    65  		}
    66  		a := make([]float64, m*lda)
    67  		for i := range a {
    68  			a[i] = rnd.NormFloat64()
    69  		}
    70  		d := make([]float64, nb)
    71  		for i := range d {
    72  			d[i] = math.NaN()
    73  		}
    74  		e := make([]float64, nb)
    75  		for i := range e {
    76  			e[i] = math.NaN()
    77  		}
    78  		tauP := make([]float64, nb)
    79  		for i := range tauP {
    80  			tauP[i] = math.NaN()
    81  		}
    82  		tauQ := make([]float64, nb)
    83  		for i := range tauP {
    84  			tauQ[i] = math.NaN()
    85  		}
    86  		x := make([]float64, m*ldx)
    87  		for i := range x {
    88  			x[i] = rnd.NormFloat64()
    89  		}
    90  		y := make([]float64, n*ldy)
    91  		for i := range y {
    92  			y[i] = rnd.NormFloat64()
    93  		}
    94  		aCopy := make([]float64, len(a))
    95  		copy(aCopy, a)
    96  
    97  		// Compute the reduction.
    98  		impl.Dlabrd(m, n, nb, a, lda, d, e, tauQ, tauP, x, ldx, y, ldy)
    99  
   100  		if m >= n && nb == n {
   101  			tauP[n-1] = 0
   102  		}
   103  		if m < n && nb == m {
   104  			tauQ[m-1] = 0
   105  		}
   106  		checkBidiagonal(t, m, n, nb, a, lda, d, e, tauP, tauQ, aCopy)
   107  	}
   108  }