Party swapping was broken
This commit is contained in:
parent
30f9cdc120
commit
c7fe98e620
36
src/cg.c
36
src/cg.c
|
@ -272,11 +272,29 @@ void FromPToCg(const size_t a_out, const size_t b_out, const size_t a_in,
|
|||
}
|
||||
}
|
||||
|
||||
// To perform a swap for every combination, we need only to consider tuples
|
||||
//
|
||||
// (oA, oB, iA, iB)
|
||||
//
|
||||
// such that, when lexicographically ordered (and we take this order to be
|
||||
// right-to-left, in the sense that a greater iB places an entry later, then
|
||||
// a greater iA, and so on), we have that
|
||||
//
|
||||
// (oA, oB, iA, iB) < (oB, oA, iB, iA)
|
||||
//
|
||||
// meaning the left-hand side comes before, in the ordering, to the right-hand
|
||||
// side.
|
||||
// (The case where the two sides are equal is not covered, but that case does
|
||||
// not require a swap.)
|
||||
//
|
||||
// This can easily be seen to mean that we require
|
||||
//
|
||||
// iB < iA OR (iB = iA AND oB < oA)
|
||||
void PSwapParties(const size_t out, const size_t in, data_t *p) {
|
||||
for (size_t a_out_i = 0; a_out_i < out; a_out_i++) {
|
||||
for (size_t b_out_i = a_out_i + 1; b_out_i < out; b_out_i++) {
|
||||
for (size_t a_in_i = 0; a_in_i < in; a_in_i++) {
|
||||
for (size_t b_in_i = a_in_i + 1; b_in_i < in; b_in_i++) {
|
||||
for (size_t a_in_i = 0; a_in_i < in; a_in_i++) {
|
||||
for (size_t b_in_i = 0; b_in_i < a_in_i; b_in_i++) {
|
||||
for (size_t a_out_i = 0; a_out_i < out; a_out_i++) {
|
||||
for (size_t b_out_i = 0; b_out_i < out; b_out_i++) {
|
||||
size_t u = PIndex(out, out, in, in, a_out_i, b_out_i, a_in_i, b_in_i);
|
||||
size_t v = PIndex(out, out, in, in, b_out_i, a_out_i, b_in_i, a_in_i);
|
||||
data_t tmp = p[u];
|
||||
|
@ -285,6 +303,16 @@ void PSwapParties(const size_t out, const size_t in, data_t *p) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t a_out_i = 0; a_out_i < out; a_out_i++) {
|
||||
for (size_t b_out_i = 0; b_out_i < a_out_i; b_out_i++) {
|
||||
size_t u = PIndex(out, out, in, in, a_out_i, b_out_i, a_in_i, a_in_i);
|
||||
size_t v = PIndex(out, out, in, in, b_out_i, a_out_i, a_in_i, a_in_i);
|
||||
data_t tmp = p[u];
|
||||
p[u] = p[v];
|
||||
p[v] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue