POLY: cleanup pb_inverse_poly_q()

Also avoid side effects.
This commit is contained in:
hasufell 2014-04-17 17:37:30 +02:00 committed by malte
parent 6990193dcd
commit 85c48647f5
1 changed files with 5 additions and 7 deletions

View File

@ -257,13 +257,16 @@ bool pb_inverse_poly_q(pb_poly * const a,
c = build_polynom(NULL, ctx->N, ctx);
f = build_polynom(NULL, ctx->N, ctx);
PB_COPY(a, f);
a_tmp = build_polynom(NULL, ctx->N, ctx);
PB_COPY(a, a_tmp);
g = build_polynom(NULL, ctx->N, ctx);
mp_set(&(g->terms[0]), 1);
mp_neg(&(g->terms[0]), &(g->terms[0]));
mp_set(&(g->terms[ctx->N]), 1);
/* avoid side effects */
a_tmp = build_polynom(NULL, ctx->N, ctx);
PB_COPY(a, a_tmp);
erase_polynom(Fq, ctx->N);
while (1) {
while (mp_cmp_d(&(f->terms[0]), 0) == MP_EQ) {
for (unsigned int i = 1; i <= ctx->N; i++) {
@ -287,12 +290,8 @@ bool pb_inverse_poly_q(pb_poly * const a,
pb_exch(b, c);
}
/* draw_polynom(f); */
/* draw_polynom(b); */
pb_xor(f, g, f, ctx->N);
pb_xor(b, c, b, ctx->N);
/* draw_polynom(f); */
/* draw_polynom(b); */
}
OUT_OF_LOOP:
@ -304,7 +303,6 @@ OUT_OF_LOOP:
j = j + ctx->N;
MP_COPY(&(b->terms[i]), &(Fq->terms[j]));
}
draw_polynom(Fq);
while (v < (int)(ctx->q)) {
pb_poly *pb_tmp,