-
Notifications
You must be signed in to change notification settings - Fork 1
/
table.hoc
158 lines (144 loc) · 3.24 KB
/
table.hoc
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
146
147
148
149
150
151
152
153
154
155
156
157
objref m
ncell = 0
ncon = 1
nhost = 2
meth = 3
invl = 4
phase = 5
comp = 6
total = 7
set_maxstep = 8
proc rd() {local i localobj f
f = new File()
m = new Matrix()
f.ropen("table.dat")
m.scanf(f)
// m.printf(" %4.2f")
f.close()
m.setcol(ncon, m.getcol(ncon).div(1000))
m.setcol(nhost, m.getcol(nhost).div(1024))
m.setcol(ncell, m.getcol(ncell).div(1024*1024))
}
rd()
obfunc get() {local i, arg, val, k localobj r, si, mr, m
m = $o1
si = new Vector(m.nrow)
si.indgen
for i=2, numarg() {
arg = $i
i += 1
val = $i
//print i, arg, val
r = m.getcol(arg).index(m.getcol(arg),si).indvwhere("==", val)
//print "r.size ", r.size
//r.printf
si.index(si, r)
}
//print "si.size ", si.size
//si.printf
k = si.size
if (k == 0) k = 1
mr = new Matrix(k, m.ncol())
for i=0, si.size-1 {
mr.setrow(i, m.getrow(si.x[i]))
}
return mr
}
//get1(m, nhost,64, ncon,1).printf
proc append() { localobj vv, m2
vv = $o1 m2 = $o2
if (m2.nrow == 0) { m2 = new Matrix(1,20) }
vv.append(m2.x[0][comp])
vv.append(m2.x[0][total])
vv.append(m2.x[0][set_maxstep])
}
obfunc line() {localobj mr, m2, vv
vv = new Vector()
mr = get(m, nhost, $1, ncell, $2, ncon, $3)
// mr.printf()
vv.append(mr.x[0][nhost])
vv.append(mr.x[0][ncell])
vv.append(mr.x[0][ncon])
m2 = get(mr, meth, 0) append(vv, m2)
m2 = get(mr, meth, 1, invl, 2, phase, 1) append(vv, m2)
m2 = get(mr, meth, 2, invl, 2, phase, 1) append(vv, m2)
m2 = get(mr, meth, 3, invl, 1, phase, 0) append(vv, m2)
// m2 = get(mr, meth, 3, invl, 2, phase, 0) append(vv, m2)
// m2 = get(mr, meth, 2, invl, 1, phase, 1) append(vv, m2)
// m2 = get(mr, meth, 2, invl, 1, phase, 0) append(vv, m2)
// m2 = get(mr, meth, 2, invl, 2, phase, 0) append(vv, m2)
return vv
}
obfunc tab() {local i, j, k, kk, nc localobj m, vv, s, sf
sf = new StringFunctions()
m = new Matrix(4, line(8,$1,$2).size)
j = 0
for case(&i, 8, 16, 32, 64) {
if ($2 == 0 && $1 == 1) { nc = 2 }
if ($2 == 0 && $1 == 10) { nc = .25 }
if ($2 == 1 && $1 == 1) { nc = 2*i/8 }
if ($2 == 1 && $1 == 10) { nc = .25*i/8 }
vv = line(i, nc, $1)
m.setrow(j, vv)
printf("%2dK", vv.x[0])
if (vv.x[1] < 1) {
printf(" & 1/%dM", 1/vv.x[1])
}else{
printf(" & %3dM", vv.x[1])
}
printf(" & %2dk", vv.x[2])
s = new String()
for k=3, vv.size-1 {
sprint(s.s, "%.3g", vv.x[k])
for kk=sf.len(s.s), 3 {
if (sf.substr(s.s, ".") == -1) {
sprint(s.s, "%s.", s.s)
}else{
sprint(s.s, "%s0", s.s)
}
}
if (vv.x[k] == 0) { s.s = " ---" }
printf(" & %s", s.s)
}
printf(" \\\\\n")
j += 1
}
//m.printf(" %4.2f")
return m
}
objref glist
glist = new List()
objref mark
mark = new List()
mark.append(new String("T"))
mark.append(new String("t"))
mark.append(new String("O"))
mark.append(new String("o"))
proc pline() {
$o2.mark($o6, $o1, $s5, 10, $3, $4)
$o2.line($o6, $o1, $3, $4)
}
proc grph() {local i, j, n localobj x, y, g
g = new Graph() glist.append(g)
g.size(0, 5, 0, 30)
if ($2) {
g.size(0, 5, 0, 5)
g.beginline(1, 6)
g.line(1,4) g.line(4,1) g.flush()
}
for j = 1, 4 {
n = j*2 + 2 + j - 1
x = $o1.getcol(0)
y = $o1.getcol(n)
x.div(4).log.div(log(2))
if ($2) {
y.log.div(log(2))
}
pline(x, y, 1, 1, mark.o(j-1).s, g)
}
}
objref mm
grph(tab(1, 0), 1)
grph(tab(10, 0), 1)
grph(tab(1, 1), 0)
grph(tab(10, 1), 0)