Commit 05bb068e authored by Charles Bouillaguet's avatar Charles Bouillaguet
Browse files

solver tweaks

parent 1a4168c5
......@@ -451,8 +451,6 @@ void oblivious_solve(const struct vector_enumeration_state_t *ves, int l, int v,
assert(l <= 128);
assert(v <= l);
*rank_defect = zero();
/* copy to sensible data structure */
vector A[128][64];
for (int i = 0; i < l; i++) {
......@@ -465,10 +463,9 @@ void oblivious_solve(const struct vector_enumeration_state_t *ves, int l, int v,
/* solve Ax == b */
for (int j = 0; j < v; j++) {
/* do the job on column j */
vector column_ok = A[j][j];
/* find a pivot on column j */
for (int i = j + 1; i < l; i++) {
vector swap = A[i][j] & (~column_ok);
vector swap = A[i][j] & (~A[j][j]);
// conditionnaly swap rows i and j
for (int k = 0; k < v; k++) {
vector xor = swap & (A[i][k] ^ A[j][k]);
......@@ -478,9 +475,7 @@ void oblivious_solve(const struct vector_enumeration_state_t *ves, int l, int v,
vector xor = swap & (b[i] ^ b[j]);
b[i] ^= xor;
b[j] ^= xor;
column_ok |= swap;
}
*rank_defect |= ~column_ok;
// eliminate everything below row j
for (int i = j + 1; i < l; i++) {
......@@ -496,10 +491,16 @@ void oblivious_solve(const struct vector_enumeration_state_t *ves, int l, int v,
for (int j = i + 1; j < v; j++)
b[i] ^= A[i][j] & b[j];
// elimination complete, check consistency. b[0:v] contains a solution if consistent
*consistent = one();
for (int i = v; i < l; i++)
*consistent &= (~b[i]);
// elimination complete, check consistency and rank. b[0:v] contains a solution if consistent
vector full_rank = A[0][0];
for (int j = 1; j < v; j++)
full_rank &= A[j][j];
*rank_defect = ~full_rank;
vector inconsistent = b[v];
for (int i = v + 1; i < l; i++)
inconsistent |= b[i];
*consistent = ~inconsistent;
}
/*************************** processing candidate solutions***************************/
......@@ -668,7 +669,7 @@ int main(int argc, char **argv)
}
double stop = wtime();
fprintf(stderr, "Done in %.1fs\n", stop - start);
fprintf(stderr, "Done in %.2fs\n", stop - start);
fprintf(stderr, "%" PRId64 " expensive iterations\n", n_expensive);
fprintf(stderr, "%" PRId64 " consistent systems\n", n_consistent);
fprintf(stderr, "%" PRId64 " defective systems\n", n_defective);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment