Bill Allombert on Fri, 03 May 2024 18:19:43 +0200


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

Re: Simpler PARI/GP code than this?


On Fri, May 03, 2024 at 02:52:24PM +0200, hermann@stamm-wilbrandt.de wrote:
> GIMPS mprime software creates ".proof" files for fast verification of a
> completed (long time) PRP proof/disproof.
> 
> I asked about software to verify such .proof, and @Prime95 provided main.c
> and roots.c.
> The missing rootsdata.txt can be created with GP:
> 
> I came up with this GP script to create rootsdata.txt, verify_PRP could be
> compiled and used (generation of PRP proof for 9.4million decimal digit
> prime took 6:12h (with 16 threads), verification took only 5:17min):
> 
> https://www.mersenneforum.org/showthread.php?p=656165&postcount=7
> 
> z(p) = znorder(Mod(2,p));
> o=[List()|i<-[1..2^16]];
> forprime(p=3,2^16+1,listput(~o[z(p)],p));
> {
>   for(i=1,2^16,if(#o[i],
>     print1("-", i,",");
>     foreach(o[i],x,print1(" ",x,","));
>     print();
>   ));
> }
> 
> I feel that rootsdata.txt can be created with a much smaller GP script, is
> that true?

It is not that long to begin with.
What you can do is replace

     print1("-", i,",");
     foreach(o[i],x,print1(" ",x,","));
     print();

by
     print("-", i, ", ", strjoin(Vec(o[i]), ", "), ",");

Also, if you just the latest GIT master branch, you can use a map for o:

maplistput(~M,k,v) = mapapply(~M,k,(~y)->listput(~y,v),()->List(v));
z(p) = znorder(Mod(2,p));
o = Map(); forprime(p=3,2^16+1,maplistput(~o,z(p),p));
foreach(Vec(o),i, print("-", i, ", ", strjoin(Vec(mapget(o,i)), ", "), ","));

Cheers,
Bill.