Bill Allombert on Wed, 01 Feb 2012 21:49:47 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: for and sum


On Fri, Jan 27, 2012 at 09:49:15PM +0100, Bill Allombert wrote:
> Hello PARI developers,
> 
> I found out why for() is slower than sum():
> 
> (20:54) gp > for(i=1,10^8,0);
> (20:54) gp > ##
>   ***   last result computed in 7,965 ms.
> (20:54) gp > sum(i=1,10^8,0);
> (20:55) gp > ##
>   ***   last result computed in 6,584 ms.
> 
> This is due to for() allowing the lower bound not to be a t_INT.
> 
> So of course I made a branch bill-forparii which adds a function
> forparii that handle the case where a is an integer faster.
> (Patch in attachement, made with git format-patch).
> 
> (21:33) gp > for(i=1,10^8,0);
> (21:33) gp > ##
>   ***   last result computed in 5,981 ms.

I have commited this patch (62ccc60c).

Cheers,
Bill.