From 8a33545fd429ade33e2efad4ee973dbece62f560 Mon Sep 17 00:00:00 2001 From: mdw Date: Tue, 15 Aug 2000 21:45:05 +0000 Subject: [PATCH] Use the new trial division equipment in pfilt. This gives a 10% performance improvement in dsa-gen.t. --- dsa-gen.c | 18 +++++++----------- limlee.c | 15 ++++++++------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/dsa-gen.c b/dsa-gen.c index 3943dd5..2d89115 100644 --- a/dsa-gen.c +++ b/dsa-gen.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: dsa-gen.c,v 1.6 2000/07/29 10:00:14 mdw Exp $ + * $Id: dsa-gen.c,v 1.7 2000/08/15 21:45:05 mdw Exp $ * * Generate DSA shared parameters * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: dsa-gen.c,v $ + * Revision 1.7 2000/08/15 21:45:05 mdw + * Use the new trial division equipment in pfilt. This gives a 10% + * performance improvement in dsa-gen.t. + * * Revision 1.6 2000/07/29 10:00:14 mdw * Rename `dsa_seed' to `dsa_gen' for consistency with other parameter- * generation interfaces. @@ -100,15 +104,7 @@ static int next(pgen_event *ev, dsa_stepctx *d) /* --- Do the trial division --- */ - { - mp *g = MP_NEW; - mp_gcd(&g, 0, 0, m, primorial); - if (MP_CMP(g, ==, MP_ONE) || MP_CMP(g, ==, m)) - rc = PGEN_TRY; - else - rc = PGEN_FAIL; - mp_drop(g); - } + rc = pfilt_smallfactor(m); /* --- Return the result --- */ @@ -265,7 +261,7 @@ static int verify(dstr *v) if (!rc) { mp_drop(dp.q); mp_drop(dp.p); mp_drop(dp.g); } - assert(mparena_count(MPARENA_GLOBAL) == 1); /* Primorial! */ + assert(mparena_count(MPARENA_GLOBAL) == 0); return (ok); } diff --git a/limlee.c b/limlee.c index dd03866..45f579d 100644 --- a/limlee.c +++ b/limlee.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: limlee.c,v 1.3 2000/07/29 09:58:32 mdw Exp $ + * $Id: limlee.c,v 1.4 2000/08/15 21:45:05 mdw Exp $ * * Generate Lim-Lee primes * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: limlee.c,v $ + * Revision 1.4 2000/08/15 21:45:05 mdw + * Use the new trial division equipment in pfilt. This gives a 10% + * performance improvement in dsa-gen.t. + * * Revision 1.3 2000/07/29 09:58:32 mdw * (limlee): Bug fix. Old versions didn't set the filter step if @ql@ was * an exact divisor of @pl@. @@ -168,7 +172,6 @@ mp *limlee(const char *name, mp *d, mp *newp, /* --- Now allocate the working memory --- */ - primorial_setup(); v = xmalloc(mm * sizeof(mp *)); c = xmalloc(mm); @@ -226,20 +229,18 @@ again: { mp *p = mpmul_done(&mmul); - mp *g = newp; + mp *g; int rc; /* --- Check for small factors --- */ p = mp_lsl(p, p, 1); p = mp_add(p, p, MP_ONE); - mp_gcd(&g, 0, 0, p, primorial); - if (MP_CMP(g, !=, MP_ONE)) { - mp_drop(g); + rc = pfilt_smallfactor(p); + if (rc == PGEN_FAIL) { mp_drop(p); continue; } - mp_drop(g); /* --- Send an event out --- */ -- 2.11.0