/* -*-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
pfilt f; /* The rapid prime filter */
} pgen_filterctx;
-extern int pgen_filter(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_filter;
/* --- @pgen_jump@ --- *
*
pfilt f;
} pgen_jumpctx;
-extern int pgen_jump(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_jump;
/* --- @pgen_test@ --- *
*
* @rabin@ context.
*/
-extern int pgen_test(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_test;
+
+/*----- Simultaneous primality checking -----------------------------------*/
+
+typedef struct pgen_simulprime {
+ mp *mul, *add; /* Arguments from the client */
+ unsigned f; /* Flags, set by client, changed */
+#define PGENF_KEEP 1u /* Keep this prime's value */
+#define PGENF_JUMP 8u /* Use jump table, not stepping */
+ pfilt p; /* This prime's filter */
+ rabin r; /* Rabin testing context */
+ union {
+ mpw step; /* The simple step to use */
+ pfilt *jump; /* The jump to move by */
+ mp *x; /* The result, if wanted */
+ } u;
+} pgen_simulprime;
+
+typedef struct pgen_simulctx {
+ pgen_simulprime *v; /* Vector of related primes */
+ unsigned n; /* Size of the vector */
+ mp *step; /* Basic stepping value */
+} pgen_simulctx;
+
+/* --- @pgen_simulstep@ --- *
+ *
+ * Step a collection of numbers simultaneously.
+ */
+
+extern pgen_proc pgen_simulstep;
+
+/* --- @pgen_simultest@ --- *
+ *
+ * Test a collection of numbers simultaneously.
+ */
+
+extern pgen_proc pgen_simultest;
/*----- Safe prime functions ----------------------------------------------*/
pfilt q, p;
} pgen_safestepctx;
-extern int pgen_safestep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_safestep;
+
+/* --- @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 pgen_proc pgen_safejump;
/* --- @pgen_safetest@ --- *
*
rabin q, p;
} pgen_safetestctx;
-extern int pgen_safetest(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_safetest;
+
+/*----- 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 pgen_proc pgen_gcdstep;
/*----- Standard event handlers -------------------------------------------*/
* Displays a spinning baton to show progress.
*/
-extern int pgen_evspin(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_evspin;
/* --- @pgen_ev@ --- *
*
* Traditional event handler, shows dots for each test.
*/
-extern int pgen_ev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_ev;
+
+/* --- @pgen_subev@ --- *
+ *
+ * Subsidiary event handler, mainly for Lim-Lee searches and so on.
+ */
+
+extern pgen_proc pgen_subev;
/*----- The main driver ---------------------------------------------------*/
* @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