projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove vestiges of @primorial@.
[u/mdw/catacomb]
/
prim.c
diff --git
a/prim.c
b/prim.c
index
bdad98b
..
31ef919
100644
(file)
--- a/
prim.c
+++ b/
prim.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: prim.c,v 1.
1 1999/12/22 15:58:59
mdw Exp $
+ * $Id: prim.c,v 1.
2 2000/07/29 09:57:42
mdw Exp $
*
* Finding primitive elements
*
*
* Finding primitive elements
*
@@
-30,6
+30,11
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: prim.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: prim.c,v $
+ * Revision 1.2 2000/07/29 09:57:42 mdw
+ * Improve primitive-element testing a lot. Now much more sensible and
+ * orthogonal: you can find a generator for any given subgroup order by
+ * putting in the appropriate parameters.
+ *
* Revision 1.1 1999/12/22 15:58:59 mdw
* Search for primitive elements using prime-search equipment.
*
* Revision 1.1 1999/12/22 15:58:59 mdw
* Search for primitive elements using prime-search equipment.
*
@@
-57,27
+62,37
@@
int prim_test(int rq, pgen_event *ev, void *p)
case PGEN_BEGIN:
return (PGEN_TRY);
case PGEN_TRY: {
case PGEN_BEGIN:
return (PGEN_TRY);
case PGEN_TRY: {
- mp *x = MP_NEW;
- mp *f = c->f;
+ mp *x;
rc = PGEN_FAIL;
rc = PGEN_FAIL;
- x = mpmont_exp(&c->mm, x, ev->m, f);
- if (MP_CMP(x, ==, MP_ONE))
- goto done;
- if (c->n == 0) {
- mp_drop(ev->m);
- ev->m = MP_COPY(x);
- } else {
- size_t n = c->n - 1;
- f++;
+ if (!c->exp)
+ x = mp_copy(ev->m);
+ else {
+ x = mpmont_exp(&c->mm, MP_NEW, ev->m, c->exp);
+ if (MP_CMP(x, ==, MP_ONE))
+ goto done;
+ }
+ if (c->n == 0)
+ goto ok;
+ else {
+ size_t n = c->n;
+ mp **f = c->f;
+ mp *y = MP_NEW;
while (n) {
while (n) {
- x = mpmont_exp(&c->mm, x, ev->m, f);
- if (MP_CMP(x, ==, MP_ONE))
+ y = mpmont_exp(&c->mm, y, x, *f);
+ if (MP_CMP(y, ==, MP_ONE)) {
+ mp_drop(y);
goto done;
goto done;
+ }
n--; f++;
}
n--; f++;
}
+ mp_drop(y);
}
}
+ ok:
rc = PGEN_DONE;
rc = PGEN_DONE;
+ mp_drop(ev->m);
+ ev->m = x;
+ break;
done:
mp_drop(x);
} break;
done:
mp_drop(x);
} break;