Moving LOOP_ON_SIEVE_* macros to gmp-impl.h

Seth Troisi braintwo at gmail.com
Tue Mar 17 00:55:45 UTC 2020


The code in mpz/primorial_ui.c and tests/devel/primes.c is fairly
self-documenting but I added this comment to gmp-impl.h

-/* primesieve macros and functions */
+/*
+ * primesieve macros and functions
+ *
+ * These macros are used to iterate over primes found by gmp_primesieve
+ * which are stored in a compact bit format (excluding multiples of 2 and
3).
+ *
+ * See mpz/primorial_ui.c for a complete example.
+ * Generic use is
+ *   size = primesieve_size (end);
+ *   sieve = __GMP_ALLOCATE_FUNC_LIMBS (size);
+ *   primepi = gmp_primesieve (sieve, end);
+ *   LOOP_ON_SIEVE_BEGIN (<name of prime variable>,
+                          sieve_n_to_bit(<start>), sieve_n_to_bit (end),
0, sieve);
+ *   <DO SOMETHING WITH <name of prime variable>>
+ *   LOOP_ON_SIEVE_END;
+ *
+ * If the loop needs to be broken into different stages (up to sqrt(end),
rest)
+ * LOOP_ON_SIEVE_CONTINUE and LOOP_ON_SIEVE_STOP can be used.
+ */


On Mon, Mar 16, 2020 at 3:29 AM Niels Möller <nisse at lysator.liu.se> wrote:

> Seth Troisi <braintwo at gmail.com> writes:
>
> > It's not clear where this should be documented, if someone tells me I'm
> > happy to add some documentation.
>
> Since it's an internal interface, it doesn't need documentation in the
> user manual. Documentation in comments in gmp-impl.h is fine, I think.
>
> Regards,
> /Niels
>
> --
> Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
> Internet email is subject to wholesale government surveillance.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LOOP_ON_S_macros2.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-devel/attachments/20200316/a1de9011/attachment-0001.bin>


More information about the gmp-devel mailing list