Max Alekseyev on Mon, 27 Nov 2017 02:36:15 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: suppress warnings in GP |
* Max Alekseyev [2017-11-26 18:21]:
> Is there a way to suppress warnings in GP like this one?
>
> *** _^_: Warning: Mod(a,b)^n with n >> b : wasteful.
I just killed it in the 'master' branch, together with the section of
code which attempted to improve on user's programming in this case.
The warning meant that we were computing Mod(a,b)^n with b < 2^64 <= |n|.
It is usually the case that gcd(a,b) = 1, in which case n can
be reduced mod eulerphi(b); if not, the computation should be simplified
by using CRT. Etc.
Compare
? p=1009; n = 2^64+1; N = n%(p-1);
? for(i=2,10^5, Mod(i,p)^N) \\ correct
time = 30 ms.
? for(i=2,10^5, Mod(i,p)^n) \\ silly => 6 times slower
time = 190 ms.
The corresponding library code was complicated and error-prone (because of the
need to cater for gcd(a,b) > 1); I actually spotted an error when I
reviewed it because of your mail.
I decided it was not worth it, the recovery code and warning are both
gone: let users fix their code if they care about efficiency, they know best.
Cheers,
K.B.
--
Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17
Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23
351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ Talence (France) http://pari.math.u-bordeaux.
F-33405fr/ [PARI/GP]
`