Bill Allombert on Wed, 03 Jan 2024 11:33:02 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Can I speed up / reduce the stack used by this PARI/GP script?
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Can I speed up / reduce the stack used by this PARI/GP script?
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Wed, 3 Jan 2024 11:32:58 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1704277979; c=relaxed/relaxed; bh=1Z1mWipGlZYv7LeC7blELCbrt6YSulGYXFA4e8oncEE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=cwwYwbY9FYToXGGZIvizE2Xa21TvGTHpb6Rtpgzwq2xzaVTPWP3bP4U2d660vRcfnTj9Zn+61q0APBIbV6iExC0XCjS2F+21J+ReRSv8FPf3DZzEHISKfG9I7ClJOueQ6xRUKBwmh53w4SBL/qpgeetgFucVnFB7G3g+EpduIW2uEaQwyrfEedQYoNNiYhhW5CNpCJQJrSWUWWE8JKdAVrNanjmROrQLbkpXthcn1lcRuAvFqnlWx9I+Nq+Rk/ByIhIx99mWzbP9LYFujM6EDTpZueIIUrKkUuBggoe8XiFKg5Y5eItGqqeIz4ZON8NYelBZ67R9SAj/39khXCi78vceN7FbQ6Gi1H5XBc0ADoQSk7btj1vJeiN+fvkQCitdWMiKEXwKGnLjHChRLhFNobKZ3IpZQqa8jWa3mVEZtzCNBgLUa+UierEnLMsYPJENKABndLrjb4fhx4BO55wk+Nikr4isQd6XQJuqEmMxNGtpcMASMIgYAneHztFuuT80dn9bkAaQhEvlLTorQLBn/xVqcsT5iCulLq9i05V1woFd4B2Fu1WviZjif+eage+w1J/hy9VpEJIHXC0pszf5azAePCtgiqV9WJnsq0tYWCTQkeaEztewj7sglxDPbciTJUAvW5wwgC53NNpxXS3c81BNP4JUy1AsBpixp6MZhYQ=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1704277979; cv=none; b=E+MDrkGv2Uct1st3pBXfQjVbz1b+unRgTWqwYQ5Yv37ioiwIk/OF3DKmdWfQ031HUjuzP+qeiYevbaCyVF3ttuPW12GAwloKmQRzLHd4h4QFDlxUX2RyNcRRg0OugeW86eacTfjVGFtqMeQKvPBaUbf8O6aAipup+YJb0HMZ7V5O2QoSFMpwMNixrGrTV8uVQMAvYcwNBOyVChmKQuaROVE6raBG23xnhfzXWIwexKSINHvNPZp0D5uZP7Ej5BI6L7rXgqohLhHRjM5SHQpcj1I9ejRGOrcuETw+H7rhOizqcfAsWaEnHJ57FuFv+hidYtD+qVM9fEuh7A9EuiKrQ/2imlMInx9A2itkakWsKtqM3fjsQi2LDMDzrIJNYXSD8RqP+0kS1c4XAf/Zg+BKurFKKU1y3rb8rran2MBSowIlSDymS8VMKYCoa3dnRZrLzydY/EO5mD0tUnd/6uY24r0HCl7hugiGmGjmnakTMVJ9d42yz+CS2+mKGOLr4CFeEeXfMcvbsjfoyHwkRFm2aCfsX7xCiksWx6Q4apmbs9hvZmjU5mRD3QDO3wWxnVwmVXdrwA743pf3OkSC87JSQAG3UXClGl3odQLqomY+O2S6ptiv8yx38YDRef8EXkm7ij7uKHYQU1rq5Xi8SFXZTHqXRY1Qg0qN6X1teR4VItM=
- Authentication-results: smail; arc=none
- Delivery-date: Wed, 03 Jan 2024 11:33:03 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1704277979; bh=1Z1mWipGlZYv7LeC7blELCbrt6YSulGYXFA4e8oncEE=; h=Date:From:To:Subject:References:In-Reply-To:From; b=rxrllWnEzEfJKOo9GM3l/JnbUpGU/NUqGVAch9k4RzRNUu6Mem+g5f+jAjd82w1Nn 0dLatJj9VfQ66MTSvAHtAFONnh6KN21MmmErO1U+2cVJGwpWhTrbdSbd6IV3vzs+8X /8X0GLXHFBey+RqbqyuWFMTfz/lInEHDYsHTkHmZkGGO7EY2hrn8z8jtW8Fj/W2/VY UYDjsy6eldCxhoV9nGl/V16Yaa3YLG1R0Nj7suO18GMRBFtRomGX0Jkz08U/Ob/P6m gsCBVFBvk4Ia89x46jLMZP7l67VZOHO9kmNt1q4Rgsipb3F5CJlCC8ua0TBYXNzJqk rno2itIdZrw4bTUtSSsOjAuyuNsm2vgnBrfZ7vXabMOMhuJy/AiS9CsblbJb8GXMAC iWkAFF9TDHmXBIPlE69s1JmXIwXwSzeYzQZuKfjCbBVtWdVIXucXYkLMIU4BdXoYoz z7JuG+D11TK07tddSYVnpK6tmYGYc8HmcqIdQ+UpQsW8irxJ3H4uNiHlKcwa9EhUkV 62e8iLUPh3J+S71IgNxTFjGzi//nQIVAO2gN8LM1l5fWF+GyBXcSa8oXGznZXDgn9q zjOfYKU4+iYEeEcdTA8VsssLpv+OgwSsbgw0O8BsvK1sEIxYcPBRcOMkKVKrCItcHY 9lSnYwzMxQkpeUa2ni+ClkTY=
- In-reply-to: <CAEdMSjd4FG+4OMNwd1vLuZi2+gTUYGnhcKBJeqUhfuh6+zx4mQ@mail.gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <CAEdMSjd4FG+4OMNwd1vLuZi2+gTUYGnhcKBJeqUhfuh6+zx4mQ@mail.gmail.com>
On Wed, Jan 03, 2024 at 12:13:52PM +1100, Joe Slater wrote:
> I wrote the following script to calculate terms of A060322. It does a
> decent job, but takes a lot of memory: at present I can only calculate
> around 70 terms. Can anyone suggest a way to push it further?
>
> A060322(n)= /* Provide an array from 1..n of the number of integers with a
> stopping time of _n_ */
> {
> my(v=vector(n,i,[]));
> v[1]=[1];
> my(v2=v3=v4=[]);
> if(n>4,
> for(x=5,n,
> v2=vector(x-1,i,[(x-1)/3| x<-2^(x-i)*v[i],(x%3)==1]);
Just an advice: you are using x for two different loop indices which makes
you code a bit difficult to read.
v2=vector(x-1,i,[(y-1)/3| y<-2^(x-i)*v[i],(y%3)==1]);
is easier to understand.
Now the computational problem is that the vector v2 become exponentially large with n.
I do not know how to avoid that.
Cheers,
Bill