Pedro Fortuny Ayuso on Thu, 13 Nov 2014 10:50:50 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
(Modular ^) vs. (^ then mod) |
Hi, I am doing quite a few (millions) of modular powers and additions like shown below. Is it natural that the Mod operation takes longer than the operation without Mod? It may be as simple as "yes, pretty normal" but somehow I expected the operation with the Mods to be faster, but I may well be quite wrong. Thank you, Pedro. ---- Pari session ? # timer = 1 (on) ? n = 120 time = 0 ms. ? s=[0,0;0,0]; time = 0 ms. ? for(a=0,n-1, for(b=0, n-1, for(c=0, n-1, s=s+[a,b;0,c]^n))) time = 12,315 ms. ? s=[0,0;0,0]; time = 0 ms. ? for(a=0,n-1, for(b=0, n-1, for(c=0, n-1, s=s+[Mod(a,n),Mod(b,n);0,Mod(c,n)]^n))) time = 18,268 ms. ? s=[0,0;0,0]; time = 0 ms. ? for(a=0,n-1, for(b=0, n-1, for(c=0, n-1, s=s+Mod([a,b;0,c]^n,n)))) time = 13,896 ms. -- Pedro Fortuny Ayuso http://pfortuny.net [ Dirección nueva: pedro@pfortuny.net ] [ Todas las anteriores siguen funcionando ] EPIG, Campus de Viesques, Gijon Dpto. de Matematicas Universidad de Oviedo
Attachment:
smime.p7s
Description: S/MIME cryptographic signature