| Ruud H.G. van Tol on Mon, 10 Aug 2026 00:23:02 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: creating (non)zero vector |
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