Repository navigation
Expand file tree
/
Copy pathEverythingEquationApp.cpp
More file actions
170 lines (124 loc) · 4.55 KB
/
Copy pathEverythingEquationApp.cpp
File metadata and controls
170 lines (124 loc) · 4.55 KB
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
#ifndef __EVERYTHINGEQUATIONAPP_CPP__
#define __EVERYTHINGEQUATIONAPP_CPP__
#include "SATSolver.hpp"
#include "EverythingEquationApp.hpp"
NAND_VECTOR* NAND_VECTOR_create() {
NAND_VECTOR* nand_vector = new NAND_VECTOR();
nand_vector->a = simp_vector_create(16);
nand_vector->b = simp_vector_create(16);
nand_vector->a_vtop = -1;
nand_vector->a_vcap = 16;
nand_vector->b_vtop = -1;
nand_vector->b_vcap = 16;
simp_vector_append(&(nand_vector->a), &(nand_vector->a_vtop), &(nand_vector->a_vcap), TRUE_3SAT);
simp_vector_append(&(nand_vector->b), &(nand_vector->b_vtop), &(nand_vector->b_vcap), TRUE_3SAT);
simp_vector_append(&(nand_vector->a), &(nand_vector->a_vtop), &(nand_vector->a_vcap), FALSE_3SAT);
simp_vector_append(&(nand_vector->b), &(nand_vector->b_vtop), &(nand_vector->b_vcap), FALSE_3SAT);
return nand_vector;
}
NAND_VECTOR* NAND_VECTOR_destroy(NAND_VECTOR* nand_vector) {
if (nand_vector) {
if (nand_vector->a) {
delete[] nand_vector->a;
nand_vector->a = nullptr;
}
if (nand_vector->b) {
delete[] nand_vector->b;
nand_vector->b = nullptr;
}
delete nand_vector;
nand_vector = nullptr;
}
return nand_vector;
}
void NAND_VECTOR_create_entry(NAND_VECTOR* nand_vector, __int64 a, __int64 b) {
simp_vector_append(&(nand_vector->a), &(nand_vector->a_vtop), &(nand_vector->a_vcap), a);
simp_vector_append(&(nand_vector->b), &(nand_vector->b_vtop), &(nand_vector->b_vcap), b);
}
SAT_VECTOR* SAT_VECTOR_create(NAND_VECTOR* definition) {
if (definition->a_vtop + 1 < 2) {
return nullptr;
}
SAT_VECTOR* translation = new SAT_VECTOR ();
translation->a = simp_vector_create(16);
translation->b = simp_vector_create(16);
translation->c = simp_vector_create(16);
translation->p = simp_vector_create(16);
translation->h = simp_vector_create(16);
translation->a_vtop = -1;
translation->a_vcap = 16;
translation->b_vtop = -1;
translation->b_vcap = 16;
translation->c_vtop = -1;
translation->c_vcap = 16;
translation->p_vtop = -1;
translation->p_vcap = 16;
translation->h_vtop = -1;
translation->h_vcap = 16;
__int64 first_avail_p_h_ix = 1;
__int64 k_parm = 0;
for (__int64 i = 2; i <= definition->a_vtop + 1; i++) {
__int64 c = i;
for (__int64 j = i; j >= 2; j--) {
__int64 p = first_avail_p_h_ix;
simp_vector_append(&(translation->p), &(translation->p_vtop), &(translation->p_vcap), p);
first_avail_p_h_ix++;
for (__int64 k = j-1; k >= 2; k--) {
__int64 h = first_avail_p_h_ix;
simp_vector_append(&(translation->h), &(translation->h_vtop), &(translation->h_vcap), p);
first_avail_p_h_ix++;
__int64 a = j;
__int64 b = k;
simp_vector_append(&(translation->a), &(translation->a_vtop), &(translation->a_vcap), -p);
simp_vector_append(&(translation->b), &(translation->b_vtop), &(translation->b_vcap), -a);
simp_vector_append(&(translation->c), &(translation->c_vtop), &(translation->c_vcap), h);
simp_vector_append(&(translation->a), &(translation->a_vtop), &(translation->a_vcap), -h);
simp_vector_append(&(translation->b), &(translation->b_vtop), &(translation->b_vcap), -b);
simp_vector_append(&(translation->c), &(translation->c_vtop), &(translation->c_vcap), c);
simp_vector_append(&(translation->a), &(translation->a_vtop), &(translation->a_vcap), -p);
simp_vector_append(&(translation->b), &(translation->b_vtop), &(translation->b_vcap), a);
simp_vector_append(&(translation->c), &(translation->c_vtop), &(translation->c_vcap), c);
simp_vector_append(&(translation->a), &(translation->a_vtop), &(translation->a_vcap), -p);
simp_vector_append(&(translation->b), &(translation->b_vtop), &(translation->b_vcap), b);
simp_vector_append(&(translation->c), &(translation->c_vtop), &(translation->c_vcap), c);
k_parm += 4;
}
}
}
__int64 top = translation->a_vtop + 1;
for (__int64 i = 0; i < first_avail_p_h_ix; i++) {
translation->p[i] += top;
translation->h[i] += top;
}
translation->k = k_parm;
translation->n = translation->a_vtop + first_avail_p_h_ix;
return translation;
}
SAT_VECTOR* SAT_VECTOR_destroy(SAT_VECTOR* sat_vector) {
if (sat_vector) {
if (sat_vector->a) {
delete[] sat_vector->a;
sat_vector->a = nullptr;
}
if (sat_vector->b) {
delete[] sat_vector->b;
sat_vector->b = nullptr;
}
if (sat_vector->c) {
delete[] sat_vector->c;
sat_vector->c = nullptr;
}
if (sat_vector->p) {
delete[] sat_vector->p;
sat_vector->p = nullptr;
}
if (sat_vector->h) {
delete[] sat_vector->h;
sat_vector->h = nullptr;
}
delete sat_vector;
sat_vector = nullptr;
}
return sat_vector;
}
#endif