Source file
test/fixedbugs/issue25776.go
1
2
3
4
5
6
7 package main
8
9 const (
10 Upper = true
11 blas_Upper = 121
12 badTriangle = "bad triangle"
13 )
14
15
16 type Triangular interface {
17
18
19 Tryangle() (mmmm int, kynd bool)
20 Triangle() (mmmm int, kynd bool)
21 }
22
23
24 type blas64_Triangular struct {
25 Stride int
26 Uplo int
27 }
28
29
30
31 type TriDense struct {
32 mat blas64_Triangular
33 }
34
35 func NewTriDense() *TriDense {
36 return &TriDense{
37 mat: blas64_Triangular{
38 Stride: 3,
39 Uplo: blas_Upper,
40 },
41 }
42 }
43
44 func (t *TriDense) isUpper() bool {
45 return isUpperUplo(t.mat.Uplo)
46 }
47
48 func (t *TriDense) triKind() bool {
49 return isUpperUplo(t.mat.Uplo)
50 }
51
52 func isUpperUplo(u int) bool {
53 switch u {
54 case blas_Upper:
55 return true
56 default:
57 panic(badTriangle)
58 }
59 }
60
61 func (t *TriDense) IsZero() bool {
62 return t.mat.Stride == 0
63 }
64
65
66 func (t *TriDense) ScaleTri(f float64, a Triangular) {
67 n, kind := a.Triangle()
68 if kind == false {
69 println("ScaleTri n, kind=", n, ", ", kind, " (FAIL, expected true)")
70 }
71 }
72
73
74 func (t *TriDense) ScaleTry(f float64, a Triangular) {
75 n, kind := a.Tryangle()
76 if kind == false {
77 println("ScaleTry n, kind=", n, ", ", kind, " (FAIL, expected true)")
78 }
79 }
80
81
82 func (t *TriDense) Triangle() (nnnn int, kind bool) {
83 return 3, !t.IsZero() && t.triKind()
84 }
85
86
87 func (t *TriDense) Tryangle() (int, bool) {
88 return 3, !t.IsZero() && t.triKind()
89 }
90
91 func main() {
92 ta := NewTriDense()
93 n, kind := ta.Triangle()
94 if kind == false {
95 println(" main n, kind=", n, ", ", kind, " (FAIL, expected true)")
96 }
97 ta.ScaleTri(1, ta)
98 ta.ScaleTry(1, ta)
99 }
100
View as plain text