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.
11 "golang.org/x/exp/rand"
13 "gonum.org/v1/gonum/blas"
16 type Dlacpyer interface {
17 Dlacpy(uplo blas.Uplo, m, n int, a []float64, lda int, b []float64, ldb int)
20 func DlacpyTest(t *testing.T, impl Dlacpyer) {
21 rnd := rand.New(rand.NewSource(1))
22 for _, uplo := range []blas.Uplo{blas.Upper, blas.Lower, blas.All} {
23 for _, test := range []struct {
44 a := make([]float64, m*lda)
48 b := make([]float64, m*ldb)
52 impl.Dlacpy(uplo, m, n, a, lda, b, ldb)
56 for i := 0; i < m; i++ {
57 for j := i; j < n; j++ {
58 if b[i*ldb+j] != a[i*lda+j] {
65 for i := 0; i < m; i++ {
66 for j := 0; j < min(i, n); j++ {
67 if b[i*ldb+j] != a[i*lda+j] {
74 for i := 0; i < m; i++ {
75 for j := 0; j < n; j++ {
76 if b[i*ldb+j] != a[i*lda+j] {
85 fmt.Println(blas.Lower)
86 t.Errorf("Matrices not equal after copy. Uplo = %d, m = %d, n = %d", uplo, m, n)