/* -*-c-*-
*
- * $Id: limlee.h,v 1.1 2000/07/09 21:30:58 mdw Exp $
+ * $Id: limlee.h,v 1.4 2001/02/03 11:59:07 mdw Exp $
*
* Generate Lim-Lee primes
*
/*----- Revision history --------------------------------------------------*
*
* $Log: limlee.h,v $
+ * Revision 1.4 2001/02/03 11:59:07 mdw
+ * Don't use the @pgen@ random number generator for generating primes: it's
+ * only for testing them. Use a caller-supplied one instead.
+ *
+ * Revision 1.3 2000/12/06 20:33:27 mdw
+ * Make flags be macros rather than enumerations, to ensure that they're
+ * unsigned.
+ *
+ * Revision 1.2 2000/08/18 19:16:51 mdw
+ * New stepper interface for constructing Lim-Lee primes.
+ *
* Revision 1.1 2000/07/09 21:30:58 mdw
* Lim-Lee prime generation.
*
# include "pgen.h"
#endif
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct limlee_factor {
+ mp *p; /* The actual prime */
+ unsigned tag; /* A tag, usable by the generator */
+ void *more; /* Pointer to more data */
+} limlee_factor;
+
+typedef struct limlee_stepctx {
+
+ /* --- To be initialized by the caller --- */
+
+ unsigned f; /* Various useful flags */
+ mp *newp; /* Initial valid for new primes */
+ unsigned ql, pl; /* Size of factors and result */
+ const struct limlee_primeops *pops; /* Pointer to generator ops */
+ void *pc; /* Context ptr for generator ops */
+ pgen_proc *iev; /* Event handler for inner @pgen@ */
+ void *iec; /* Context for inner @pgen@ */
+ grand *r; /* Random number generator */
+
+ /* --- Output values --- */
+
+ size_t nf; /* Number of factors wanted */
+ limlee_factor *v; /* Vector of factors */
+
+ /* --- Maintained internally --- */
+
+ octet *c; /* Combination byte-flag vector */
+ unsigned long seq; /* Sequence number for primes */
+ size_t poolsz; /* Size of the small-prime pool */
+ dstr d; /* String for subprime name */
+ limlee_factor qq; /* Big prime to pick up slack */
+
+} limlee_stepctx;
+
+typedef struct limlee_primeops {
+ void (*pgen)(limlee_factor */*f*/, unsigned /*pl*/, limlee_stepctx */*l*/);
+ void (*pfree)(limlee_factor */*f*/, limlee_stepctx */*l*/);
+} limlee_primeops;
+
+/* --- Flags --- */
+
+#define LIMLEE_KEEPFACTORS 1u
+
+/*----- The Lim-Lee stepper function --------------------------------------*/
+
+extern int limlee_step(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
/*----- Functions provided ------------------------------------------------*/
/* --- @limlee@ --- *