Max Alekseyev on Sun, 09 Aug 2026 17:17:41 +0200


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

creating (non)zero vector


Hello,

I thought that creating nonzero vector (say, of all 1s) like

allocatemem(2^31);
V = vector(10^8,i,1);

is more efficient than first creating a zero vector and then filling it with the required values:

allocatemem(2^31);
V = vector(10^8);
for(i=1,#V,V[i]=1);

In reality, the latter code works fine, but the former one results in "the PARI stack overflows" error, which is quite counterintuitive. 
Is such behavior expected?

Regards,
Max