forked from openshift/origin
/
dsyr.go
72 lines (68 loc) · 1.28 KB
/
dsyr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package testblas
import (
"testing"
"github.com/gonum/blas"
)
type Dsyrer interface {
Dsyr(ul blas.Uplo, n int, alpha float64, x []float64, incX int, a []float64, lda int)
}
func DsyrTest(t *testing.T, blasser Dsyrer) {
for i, test := range []struct {
ul blas.Uplo
n int
a [][]float64
x []float64
alpha float64
ans [][]float64
}{
{
ul: blas.Upper,
n: 4,
a: [][]float64{
{10, 2, 0, 1},
{0, 1, 2, 3},
{0, 0, 9, 15},
{0, 0, 0, -6},
},
x: []float64{1, 2, 0, 5},
alpha: 8,
ans: [][]float64{
{18, 18, 0, 41},
{0, 33, 2, 83},
{0, 0, 9, 15},
{0, 0, 0, 194},
},
},
{
ul: blas.Lower,
n: 3,
a: [][]float64{
{10, 2, 0},
{4, 1, 2},
{2, 7, 9},
},
x: []float64{3, 0, 5},
alpha: 8,
ans: [][]float64{
{82, 2, 0},
{4, 1, 2},
{122, 7, 209},
},
},
} {
incTest := func(incX, extra int) {
xnew := makeIncremented(test.x, incX, extra)
aFlat := flatten(test.a)
ans := flatten(test.ans)
lda := test.n
blasser.Dsyr(test.ul, test.n, test.alpha, xnew, incX, aFlat, lda)
if !dSliceTolEqual(aFlat, ans) {
t.Errorf("Case %v, idx %v: Want %v, got %v.", i, incX, ans, aFlat)
}
}
incTest(1, 3)
incTest(1, 0)
incTest(3, 2)
incTest(-2, 2)
}
}