Re: creating (non)zero vector

"Ruud H.G. van Tol" <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
On 2026-08-09 17:17, Max Alekseyev wrote:
> 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.

Also consider using Vecsmall, where appropriate.

-- Ruud
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.