Bill Allombert on Thu, 19 May 2005 00:50:47 +0200

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

Re: fordiv() memory hungry

On Wed, May 18, 2005 at 06:01:09PM -0400, Igor Schein wrote:
> Hi,
> (17:51:45) gp> fordiv(32!,x,0)
>   *** fordiv: the PARI stack overflows !
>   current stack size: 256000000 (244.141 Mbytes)
>   [hint] you can increase GP stack with allocatemem()
> Looks like fordiv() is no improvement over divisors() by virtue of
> having to create the whole static array first.  Is it possible to make
> fordiv() more memory-effcient without sacrificing the speed?

Depends if you insist about having the divisors in increasing order.
If you don't, you can use forvec() instead.
If you do, then it looks like a knapsack problem, so this is going to
be expensive.