mpz_prevprime
Niels Möller
nisse at lysator.liu.se
Thu Oct 15 07:13:27 UTC 2020
Seth Troisi <braintwo at gmail.com> writes:
> I modified the patch a tiny bit. Still hoping to get this in for an
> upcoming prime-gap search project.
Looks pretty good to me.
> +static int
> +findnext (mpz_ptr p,
> + unsigned long(*nextmod_func)(const mpz_t, unsigned long),
> + void(*nextseq_func)(mpz_t, const mpz_t, unsigned long))
I'd name the function pointer arguments to be more similar to functions
they refer to, and without the "next" and "_func" parts. Maybe mod_ui
and add_ui/incr_ui/update_ui?
And is there a good reason you need different mod functions? I haven't
been following along closely, so I don't know why the current code uses
mpz_cdiv_ui rather than mpz_fdiv_ui. It would make things a bit simpler
if we could use mpz_fdiv_ui (the standard mathematical mod operation)
always.
> +int
> +mpz_prevprime (mpz_ptr p, mpz_srcptr n)
Interface looks good to me. And if we later add a function to find the
first prime in an arithmetic progression, I think that should fit well.
Regards,
/Niels
--
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel
mailing list