Gerhard Niklasch on Fri, 24 Apr 1998 23:51:34 +0200


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

Re: Missing API in PARI?


> From: Ilya Zakharevich <ilya@math.ohio-state.edu>
> Message-Id: <199804242121.RAA10259@monk.mps.ohio-state.edu>
> Date: 	Fri, 24 Apr 1998 23:21:02 +0200
[...]
> You mean that there was a way to put a vector into a variable so that
> it the components do not occupy consequent chunks of memory?  Or is
> 
>   (blah(foo))[73] = bar
> 
> allowed?

(23:39) gp > vector(5,j,0)[2]=1
  ***   unexpected character: vector(5,j,0)[2]=1
                                              ^-

(Not that this made much sense, 'coz you wouldn't have been able to
access the remainder of the vector afterwards if the assignment had
worked!)

> Leaving the technobabble (which I cannot follow) aside, is it true
> that the default way to assign to arrays element-wise takes O(n^2) now?

How about trying it?

(23:42) gp > a=vector(200000,j,0);
time = 1,300 ms.
(23:43) gp > for(j=1,5000,a[j]=1;)
time = 170 ms.
(23:43) gp > for(j=1,10000,a[j]=1;)
time = 300 ms.
(23:43) gp > for(j=1,20000,a[j]=1;)
time = 670 ms.
(23:43) gp > for(j=1,50000,a[j]=1;)
time = 1,670 ms.
(23:43) gp > for(j=1,100000,a[j]=1;)
time = 2,780 ms.
(23:43) gp > for(j=1,200000,a[j]=1;)
time = 5,490 ms.

That's on a P133 (under otherwise heavy load).  ~28 microseconds per
iteration;  and a significant part of that is the overhead of the GP
for loop.

Enjoy, Gerhard