POLY: cleanup pb_inverse_poly_q()
Also avoid side effects.
This commit is contained in:
parent
6990193dcd
commit
85c48647f5
12
src/poly.c
12
src/poly.c
@ -257,13 +257,16 @@ bool pb_inverse_poly_q(pb_poly * const a,
|
|||||||
c = build_polynom(NULL, ctx->N, ctx);
|
c = build_polynom(NULL, ctx->N, ctx);
|
||||||
f = build_polynom(NULL, ctx->N, ctx);
|
f = build_polynom(NULL, ctx->N, ctx);
|
||||||
PB_COPY(a, f);
|
PB_COPY(a, f);
|
||||||
a_tmp = build_polynom(NULL, ctx->N, ctx);
|
|
||||||
PB_COPY(a, a_tmp);
|
|
||||||
g = build_polynom(NULL, ctx->N, ctx);
|
g = build_polynom(NULL, ctx->N, ctx);
|
||||||
mp_set(&(g->terms[0]), 1);
|
mp_set(&(g->terms[0]), 1);
|
||||||
mp_neg(&(g->terms[0]), &(g->terms[0]));
|
mp_neg(&(g->terms[0]), &(g->terms[0]));
|
||||||
mp_set(&(g->terms[ctx->N]), 1);
|
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 (1) {
|
||||||
while (mp_cmp_d(&(f->terms[0]), 0) == MP_EQ) {
|
while (mp_cmp_d(&(f->terms[0]), 0) == MP_EQ) {
|
||||||
for (unsigned int i = 1; i <= ctx->N; i++) {
|
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);
|
pb_exch(b, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw_polynom(f); */
|
|
||||||
/* draw_polynom(b); */
|
|
||||||
pb_xor(f, g, f, ctx->N);
|
pb_xor(f, g, f, ctx->N);
|
||||||
pb_xor(b, c, b, ctx->N);
|
pb_xor(b, c, b, ctx->N);
|
||||||
/* draw_polynom(f); */
|
|
||||||
/* draw_polynom(b); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_OF_LOOP:
|
OUT_OF_LOOP:
|
||||||
@ -304,7 +303,6 @@ OUT_OF_LOOP:
|
|||||||
j = j + ctx->N;
|
j = j + ctx->N;
|
||||||
MP_COPY(&(b->terms[i]), &(Fq->terms[j]));
|
MP_COPY(&(b->terms[i]), &(Fq->terms[j]));
|
||||||
}
|
}
|
||||||
draw_polynom(Fq);
|
|
||||||
|
|
||||||
while (v < (int)(ctx->q)) {
|
while (v < (int)(ctx->q)) {
|
||||||
pb_poly *pb_tmp,
|
pb_poly *pb_tmp,
|
||||||
|
Loading…
Reference in New Issue
Block a user