OSDN Git Service

test (#52)
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / lapack / testlapack / iladlc.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 "testing"
8
9 type Iladlcer interface {
10         Iladlc(m, n int, a []float64, lda int) int
11 }
12
13 func IladlcTest(t *testing.T, impl Iladlcer) {
14         for i, test := range []struct {
15                 a         []float64
16                 m, n, lda int
17                 ans       int
18         }{
19                 {
20                         a:   []float64{0, 0, 0, 0},
21                         m:   1,
22                         n:   1,
23                         lda: 2,
24                         ans: -1,
25                 },
26                 {
27                         a:   []float64{0, 0, 0, 0},
28                         m:   2,
29                         n:   2,
30                         lda: 2,
31                         ans: -1,
32                 },
33                 {
34                         a:   []float64{0, 0, 0, 0},
35                         m:   4,
36                         n:   1,
37                         lda: 1,
38                         ans: -1,
39                 },
40                 {
41                         a:   []float64{0, 0, 0, 0},
42                         m:   1,
43                         n:   4,
44                         lda: 4,
45                         ans: -1,
46                 },
47                 {
48                         a: []float64{
49                                 1, 2, 3, 4,
50                                 5, 6, 7, 8,
51                         },
52                         m:   2,
53                         n:   4,
54                         lda: 4,
55                         ans: 3,
56                 },
57                 {
58                         a: []float64{
59                                 1, 2, 3, 0,
60                                 0, 0, 0, 0,
61                         },
62                         m:   2,
63                         n:   4,
64                         lda: 4,
65                         ans: 2,
66                 },
67                 {
68                         a: []float64{
69                                 0, 0, 3, 4,
70                                 0, 0, 0, 0,
71                         },
72                         m:   2,
73                         n:   2,
74                         lda: 4,
75                         ans: -1,
76                 },
77         } {
78                 ans := impl.Iladlc(test.m, test.n, test.a, test.lda)
79                 if ans != test.ans {
80                         t.Errorf("Column mismatch case %v. Want: %v, got: %v", i, test.ans, ans)
81                 }
82         }
83 }