[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP)
From: |
Jim Meyering |
Subject: |
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP) |
Date: |
Mon, 08 Oct 2012 12:52:08 +0200 |
Pádraig Brady wrote:
> On 10/07/2012 10:00 AM, Jim Meyering wrote:
>> Torbjorn Granlund wrote:
>>> Jim Meyering <address@hidden> writes:
>>>
>>> How about this in place of the final sentence?
>>>
>>> The new program also
>>> runs a deterministic primality test for each prime factor, not just
>>> a probabilistic test.
>>>
>>> That's better, thanks.
>>
>> I pushed the actual bug fix (for the issue mentioned in the Subject)
>> long ago, so I'm closing this "issue".
>>
>> Regarding your upcoming improvements, please start a new thread
>> when you're ready to discuss them, so that your comments are not
>> lost in the volume of with this now-"done" bug report.
>
> A small amendment I'm going to push is not to rely on GMP5.
> GMP4 on my fedora 15 system doesn't have mpz_inits().
> i.e. support for initializing multiple variables at once.
>
> Patch is simple enough...
Hi Pádraig,
Thanks, but wouldn't that be a slight "pessimization"?
What do you think about providing the missing function instead?
Maybe not worth the hassle, but still, it would avoid adding those 12
in-function lines. factor.c is already large and complex enough that
every little bit helps.
BTW, Fedora 15 passed "end of life" back in June.
> diff --git a/src/factor.c b/src/factor.c
> index 5bfbfdc..1857297 100644
> --- a/src/factor.c
> +++ b/src/factor.c
> @@ -1335,7 +1335,10 @@ mp_prime_p (mpz_t n)
> if (mpz_cmp_ui (n, (long) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) < 0)
> return true;
>
> - mpz_inits (q, a, nm1, tmp, NULL);
> + mpz_init (q);
> + mpz_init (a);
> + mpz_init (nm1);
> + mpz_init (tmp);
...