"Fossies" - the Fresh Open Source Software Archive

Member "pari-2.13.1/src/test/in/qfbsolve" (4 Jan 2021, 1346 Bytes) of package /linux/misc/pari-2.13.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "qfbsolve": 2.13.0_vs_2.13.1.

    1 chk(q,V,n)=if(#Set(V)!=#V,return(0));for(i=1,#V,if(qfeval(q,V[i])!=n,return(0)));1;
    2 
    3 bqfb(N=10000)=
    4 {
    5   my(p,d,r,V,q,q2,Q,Q2);
    6   for(i=1,N,
    7     until(!issquare(d) && (d%4==0 || d%4==1),d=random(4000)-2000);
    8     until(p==1 || kronecker(d,p)>=0,
    9       p=random(1000)-100;
   10       if(p<3,p=1,p=nextprime(p)));
   11     q=qfbprimeform(d,p); V=Vec(q); q2=Qfb(V[3],V[2],V[1]);
   12     until(Q!=0||Q2!=0,r=random([-1000,30000]);
   13       Q=qfbsolve(q,r,1);Q2=qfbsolve(q2,r,1));
   14     if(Q2==0||!chk(q2,Q2,r),print("qfbsolve(",q2,",",r,")!=",Q2);break);
   15     if(Q==0 ||!chk(q,Q,r),print("qfbsolve(",q,",",r,")!=",Q);break));
   16 }
   17 bqfb();
   18 test(v,N,flag=1)=
   19 {
   20   my([a,b,c]=v, q=Qfb(a,b,c));
   21   for(i=-N,N,my(Q=qfbsolve(q,i,flag));if(Q,print(v,":",i,":",Q)));
   22 }
   23 test([1,1,1],30);
   24 test([1,29,271],300);
   25 test([1,29,271],300,2);
   26 test([1,29,271],300,3);
   27 test([2,1,3],30);
   28 test([3,4,5],30);
   29 test([3,4,5],30,2);
   30 test([3,4,5],30,3);
   31 test([5,1,-9],30);
   32 test([5,16,7],30);
   33 test([5,16,7],30,2);
   34 test([5,16,7],30,3);
   35 N=2^128+1; F=[59649589127497217,1;5704689200685129054721,1];
   36 qfbsolve(Qfb(1,0,1),F)
   37 qfbsolve(Qfb(1,0,1),F,1)
   38 qfbsolve(Qfb(1,0,1),[N,F])
   39 qfbsolve(Qfb(1,0,1),[N,F],1)
   40 qfbsolve(Qfb(5,16,7),factor(-30),1)
   41 qfbsolve(Qfb(1,0,7*16),128,1)
   42 
   43 \\ incorrect factorization
   44 qfbsolve(Qfb(1,0,1),Mat([2^198-3,1]))
   45 qfbsolve(Qfb(1,0,1),Mat([2^198-3,1]),1)
   46 \\ ERRORS
   47 qfbsolve(Qfb(1,0,1),1,4)