-
Notifications
You must be signed in to change notification settings - Fork 16
/
reduce.go
145 lines (143 loc) · 2.03 KB
/
reduce.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package main
import (
. "github.com/ktye/wg/module"
)
func rd0(yp int32, t T, n int32) K { return 0 }
func min(yp int32, t T, e int32) K { // &/x
var xp int32
switch t - 18 {
case 0: // Ct
xp = 127
for yp < e {
xp = mini(xp, I8(yp))
yp++
}
return Kc(xp)
case 1: // It
xp = 2147483647
for yp < e {
xp = mini(xp, I32(yp))
yp += 4
}
return Ki(xp)
case 2: // St
xp = (nn(K(I64(8))) << 3) - 8
for yp < e {
xp = mini(xp, I32(yp))
yp += 4
}
return Ks(xp)
case 3: // Ft
f := inf
for yp < e {
f = F64min(f, F64(yp))
yp += 8
}
return Kf(f)
default:
return 0
}
}
func max(yp int32, t T, e int32) K { // |/x
var xp int32
switch t - 18 {
case 0: // Ct
xp = -128
for yp < e {
xp = maxi(xp, I8(yp))
yp++
}
return Kc(xp)
case 1: // It
xp = nai
for yp < e {
xp = maxi(xp, I32(yp))
yp += 4
}
return Ki(xp)
case 2: // St
xp = 0
for yp < e {
xp = maxi(xp, I32(yp))
yp += 4
}
return Ks(xp)
case 3: // Ft
f := -inf
for yp < e {
f = F64max(f, F64(yp))
yp += 8
}
return Kf(f)
default:
return 0
}
}
func sum(yp int32, t T, e int32) K { // +/x
xp := int32(0)
switch t - 18 {
case 0: // Ct
for yp < e {
xp += I8(yp)
yp++
}
return Kc(xp)
case 1: // It
return Ki(xp + sumi(yp, e))
case 2: // St
return 0
case 3: // Ft
f := 0.0
return Kf(f + sumf(yp, e, 8))
case 4: // Zt
re := 0.0
im := 0.0
return Kz(re+sumf(yp, e, 16), im+sumf(yp+8, e, 16))
default:
return 0
}
}
func sumi(xp, e int32) int32 {
r := int32(0)
for xp < e {
r += I32(xp)
xp += 4
}
return r
}
func sumf(xp, e, s int32) float64 {
r := 0.0
for xp < e {
r += F64(xp)
xp += s
}
return r
}
func prd(yp int32, t T, e int32) K { // */x
xp := int32(1)
switch t - 18 {
case 0: // Ct
for yp < e {
xp *= I8(yp)
yp++
}
return Kc(xp)
case 1: // It
for yp < e {
xp *= I32(yp)
yp += 4
}
return Ki(xp)
case 2: // St
return 0
case 3: // Ft
f := 1.0
for yp < e {
f *= F64(yp)
yp += 8
}
return Kf(f)
default:
return 0
}
}