-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcat_entries_cpp.h
177 lines (161 loc) · 4.5 KB
/
gcat_entries_cpp.h
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
extern const char* t416[416];
extern int GcatGetBandIndex(int* b0, int band1_index);
extern BANDPERM* GcatGetMappingPointer();
void GetBand1(int iw, char* bc27, int* g27) {
memcpy(bc27, "12345678945", 11);
memcpy(&bc27[11], t416[iw], 16);
for (int i = 0; i < 27; i++) {
g27[i] = bc27[i] - '1';
cout << g27[i] + 1;
}
cout << "band index " << iw << endl;
}
/*
Band index 0 -- returns an incorrect transformation about 1/2 of the time.
Band index 411 -- returns "-1" for the band type, about ~1/3 of the time.
Band index 413 -- returns an incorrect transformation, about 2/3 of the time.
Band index 415 -- returns 414 for the band type (and incorrect transformation), about 2/3 of the time.
Here are some inputs that highlight the bugs:
215486739793215468486793251 (0)
369457182184362759752189364 (411)
982641357675328914341975628 (413)
287346159694851723135972468 (413)
571962483983471526462538971 (415)
*/
const char* tbugs[5] = {
"215486739793215468486793251",
"369457182184362759752189364",
"982641357675328914341975628",
"287346159694851723135972468",
"571962483983471526462538971"
};
int tbugsid[5] = { 0,411,413,413,415 };
void InitBand1(int iw, int* g) {
char band[28]; band[27] = 0;
memcpy(band, "12345678945", 11);
memcpy(&band[11], t416[iw], 16);
band[27] = 0;
cout << band << " band index " << iw << endl;
for (int i = 0; i < 27; i++) {
g[i] = band[i] - '1';
}
}
void Go_10() {
int g[27];
int cpt = 0;
BANDPERM* mypout = GcatGetMappingPointer();
for (uint32_t ib = 0; ib <= 415; ib++) {
InitBand1(ib, g);
int ibr = GcatGetBandIndex(g, ib);
if (ibr) {
cout << ib << " erreur retour " << ibr << endl;
return;
}
else {
//cout << " band " << ib << " good" << endl;
//mypout->Morph(g, g2);
//BandDump(g2, "entry morphed");
}
ibr = GcatGetBandIndex(g, ib-1);
if(ibr<=0)cout << " r over " << ibr << endl;
ibr = GcatGetBandIndex(g, ib + 1);
if (ibr >= 0)cout << " r below " << ibr << endl;
}
}
void Go_11() {
memset(p_cpt2g, 0, sizeof p_cpt2g);
cout << "hello from go-11" << endl;
char bc[28]; bc[27] = 0;
int b0[27],b1[27];
BANDPERM* mypout= GcatGetMappingPointer();
//BMINLEX* mybmlw = GcatGetBminlex();
for (uint32_t i = 0; i < 5; i++) {
memcpy(bc, tbugs[i], 27);
for (int i = 0; i < 27; i++) {
b0[i] = bc[i] - '1';
cout << b0[i] + 1;
}
int ib = tbugsid[i];
cout << "band to see index " <<ib << endl;
int ibr = GcatGetBandIndex(b0, ib);
if (ibr) {
cout << ib << " erreur retour " << ibr << endl;
//mybmlw->Status(1);
continue;;
}
else {
cout << " band " << ib << " good" << endl;
//mybmlw->DumpMapping();
mypout->Morph(b0, b1);
BandDump(b1, "entry morphed");
//mybmlw->Status(2);
}
};
}
int CheckPermOk(BANDPERM * p, int* s, int* r) {
int d[27];
p->Morph(s, d);
int ir = BandCompare(d, r);
if (ir) {
BandDump(s, " source");
BandDump(d, " morphed");
BandDump(r, " expected");
return 1;
}
return 0;
}
void Go_12() {
memset(p_cpt2g, 0, sizeof p_cpt2g);
cout << "hello from go-12 go" << endl;
int g[27], g2[27];
int cpt = 0;
BANDPERM* mypout = GcatGetMappingPointer();
for (uint32_t ib = 0; ib <= 415; ib++) {
InitBand1(ib, g);
BANDPERM pw;
int ibr = GcatGetBandIndex(g, ib);
//pw.Dump();
if (ibr) {
cout << ib << " erreur retour " << ibr << endl;
//mybmlw->Status(1);
continue;;
}
else {
cout << " band " << ib << " good" << endl;
//mybmlw->DumpMapping();
mypout->Morph(g, g2);
BandDump(g2, "entry morphed");
//mybmlw->Status(2);
}
cpt = 0;
for (int id = 0; id < 1296; id += 10) {
int* cc = tpermorder[id];
for (int i = 0; i < 9; i++) pw.map[i] = cc[i];
//cout << "id=" << id << endl;
for (int ir = 0; ir < 6; ir++) {
//cout << "ir=" << ir << endl;
pw.rows[0] = tperm6[ir][0];
pw.rows[1] = tperm6[ir][1];
pw.rows[2] = tperm6[ir][2];
for (int ic = 0; ic < 1296; ic++) {
//cout << "ic=" << ic << endl;
int* cc = tpermorder[ic];
for (int i = 0; i < 9; i++) pw.cols[i] = cc[i];
cpt++;
pw.Morph(g, g2);
int ibr = GcatGetBandIndex(g2,ib);
if (ibr) {
cout << ib << " erreur retour " << ibr << endl;
continue;;
}
else if(CheckPermOk(mypout, g2, g)) {
cout << "stop ib= " << ib << " id=" << id << "ir=" << ir << " ic=" << ic << endl;
mypout->Dump();
return;
}
}
}
}
cout << "n calls ok " << cpt << endl;
}
}