/* -*-c-*-
*
- * $Id: pgen.h,v 1.4 1999/12/22 16:01:11 mdw Exp $
+ * $Id$
*
* Prime generation glue
*
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: pgen.h,v $
- * Revision 1.4 1999/12/22 16:01:11 mdw
- * Same file, completely different code. Main interface for new prime-
- * search system.
- *
- */
-
#ifndef CATACOMB_PGEN_H
#define CATACOMB_PGEN_H
extern int pgen_safestep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+/* --- @pgen_safejump@ --- *
+ *
+ * Jumps two numbers, %$q$% and %$p = 2q + 1$% such that neither has any
+ * small factors.
+ */
+
+typedef struct pgen_safejumpctx {
+ pfilt q, jq;
+ pfilt p, jp;
+} pgen_safejumpctx;
+
+extern int pgen_safejump(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
/* --- @pgen_safetest@ --- *
*
* Applies Rabin-Miller tests to %$p$% and %$(p - 1)/2$%.
extern int pgen_safetest(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+/*----- Miscellaneous steppers and testers --------------------------------*/
+
+typedef struct pgen_gcdstepctx {
+ pfilt p, jp; /* Prime filter and step filter */
+ mp *q, *jq; /* %$p - 1$%, and a step value*/
+ mp *r; /* Other argument for GCD */
+ mp *g; /* GCD output (must be inited) */
+ mp *max; /* Maximum permissible GCD */
+} pgen_gcdstepctx;
+
+/* --- @pgen_gcdstep@ --- *
+ *
+ * Steps @p@ and @q@, until @p@ has no small factors, and
+ * %$\gcd(p, r) \le max$%.
+ */
+
+extern int pgen_gcdstep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
/*----- Standard event handlers -------------------------------------------*/
/* --- @pgen_evspin@ --- *
extern int pgen_ev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+/* --- @pgen_subev@ --- *
+ *
+ * Subsidiary event handler, mainly for Lim-Lee searches and so on.
+ */
+
+extern int pgen_subev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
/*----- The main driver ---------------------------------------------------*/
/* --- @pgen@ --- *
* @pgen_proc *test@ = tester function to use
* @void *tctx@ = context argument for tester
*
- * Returns: If successful, @PGEN_DONE@; otherwise @PGEN_ABORT@.
+ * Returns: The resulting value, or null.
*
* Use: A generalized prime-number search skeleton. Yes, that's a
* scary number of arguments.
unsigned /*steps*/, pgen_proc */*step*/, void */*sctx*/,
unsigned /*tests*/, pgen_proc */*test*/, void */*tctx*/);
+/* --- @pgen_primep@ --- *
+ *
+ * Arguments: @mp *p@ = a number to check
+ * @grand *gr@ = a random number source
+ *
+ * Returns: Nonzero if @p@ is really prime.
+ */
+
+extern int pgen_primep(mp */*p*/, grand */*gr*/);
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus