Changeset 3d5b277 in git


Ignore:
Timestamp:
Jul 25, 2019, 1:23:11 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
35a153cf7acb82519d52d0b74581e9a193d15765
Parents:
c9824e54c705dcaedb3b991c6bf81f9f974e758d3f94cbdb24129f0002a999ab5fb63a34f0fc933d
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2019-07-25 13:23:11+02:00
git-committer:
GitHub <noreply@github.com>2019-07-25 13:23:11+02:00
Message:
Merge pull request #945 from tthsqe12/let_flint_borrow

let flint borrow large integer coeffs in some cases
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/algebra.lib

    r3f94cb r3d5b277  
    10321032  }
    10331033  // --------------------- change of variable names -------------------------
    1034   execute("ring @bsr = ("+charstr(bsr)+"),y(1..m),("+os+");");
     1034  list l2;
     1035  for (int ii = 1; ii <= m; ii++)
     1036  {
     1037    l2[ii] = "y("+string(ii)+")";
     1038  }
     1039  ring @bsr = create_ring(ringlist(bsr)[1], l2, "("+os+")", "no_minpoly");
    10351040  ideal J = fetch(bsr,J);
    10361041  ideal PHI = fetch(bsr,PHI);
  • Singular/LIB/assprimeszerodim.lib

    r3f94cb r3d5b277  
    364364//=== mapping T to p and test if d=deg(F)
    365365   def R = basering;
    366    execute("ring Rhelp = ("+charstr(R)+"), T, dp;");
     366   ring Rhelp = create_ring(ringlist(R)[1], "T", "dp", "no_minpoly");
    367367   setring R;
    368368   map phi = Rhelp,p;
  • Singular/LIB/chern.lib

    r3f94cb r3d5b277  
    33053305  int n=nvars(basering);
    33063306  def br@=basering; // remember the base ring
    3307   execute("ring r@=("+ charstr(basering) +"),("+varstr(basering)+",homvar@), dp;");
     3307  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+",homvar@)", "dp", "no_minpoly");
    33083308  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    33093309  ideal I=F(I);
  • Singular/LIB/finvar.lib

    r3f94cb r3d5b277  
    13901390    poly A(1)=M[1,2];                 // denominator of Molien series (for now)
    13911391    string mp=string(minpoly);
    1392     execute("ring R=("+charstr(br)+"),("+varstr(br)+"),ds;");
     1392    ring R = create_ring(ringlist(br)[1], "("+varstr(br)+")", "ds", "no_minpoly");
    13931393    if (mp!="0")
    13941394    {
  • Singular/LIB/goettsche.lib

    r3f94cb r3d5b277  
    8181  def br@=basering; // remember the base ring
    8282  // add additional variables z@, t@ to the base ring
    83   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     83  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    8484  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    8585  // compute the generating function by the Goettsche's formula up to degree n in t@
     
    144144  def br@=basering; // remember the base ring
    145145  // add additional variables z@, t@ to the base ring
    146   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     146  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    147147  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    148148  // compute the generating function by the Goettsche's formula up to degree n in t@
     
    208208  def br@=basering; // remember the base ring
    209209  // add additional variables z@, t@ to the base ring
    210   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     210  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    211211  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    212212  poly rez=1;
     
    267267  def br@=basering; // remember the base ring
    268268  // add additional variables z@, t@ to the base ring
    269   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     269  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    270270  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    271271  // compute the generating function by the Nakajima-Yoshioka formula up to degree n in t@
     
    322322  def br@=basering; // remember the base ring
    323323  // add additional variables z@, t@ to the base ring
    324   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     324  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    325325  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    326326  // compute the generating function by the Nakajima-Yoshioka formula up to degree n in t@
     
    377377  def br@=basering; // remember the base ring
    378378  // add additional variables z@, t@ to the base ring
    379   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     379  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    380380  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    381381  poly rez=1;
     
    434434  def br@=basering; // remember the base ring
    435435  // add additional variables z@, t@ to the base ring
    436   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     436  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    437437  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    438438  poly rez=1;
     
    485485  def br@=basering; // remember the base ring
    486486  // add additional variables z@, t@ to the base ring
    487   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     487  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    488488  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    489489  poly rez=1;
     
    536536  def br@=basering; // remember the base ring
    537537  // add additional variables z@, t@ to the base ring
    538   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", z@, t@), dp;" );
     538  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", z@, t@)", "dp", "no_minpoly");
    539539  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    540540  poly rez=1;
     
    594594  def br@=basering; // remember the base ring
    595595  // add additional variable t@ to the base ring
    596   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", t@), dp;" );
     596  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", t@)", "dp", "no_minpoly");
    597597  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    598598  poly rez=(1-t@^2)*PPolyW(q, m, n, t@, d);
     
    637637  def br@=basering; // remember the base ring
    638638  // add additional variable t@ to the base ring
    639   execute("ring r@= (" + charstr(basering) + "),("+varstr(basering)+", t@), dp;" );
     639  ring r@ = create_ring(ringlist(basering)[1], "("+varstr(basering)+", t@)", "dp", "no_minpoly");
    640640  execute( "map F= br@,"+varstr(br@)+";" ); // define the corresponding inclusion of rings
    641641  poly rez=(1-t@^2)*PPolyW(q, m, n, t@, d);
  • Singular/LIB/graal.lib

    r3f94cb r3d5b277  
    210210  {
    211211    def origin = basering;
    212     execute("ring ringForGeneralPosition = ("+charstr(basering)+"),("+varstr(basering)+"),lp;");
     212    ring ringForGeneralPosition = create_ring(ringlist(basering)[1], "("+varstr(basering)+")", "lp", "no_minpoly");
    213213    ideal m = fetch(origin,m);
    214214    newRing = 1;
  • Singular/LIB/numerAlg.lib

    r3f94cb r3d5b277  
    230230 setring W1;
    231231 number j1=jj;
    232  execute("ring q=(real,0),("+varstr(S)+"),dp;");
     232 ring q = create_ring("(real,0)", "("+varstr(S)+")", "dp");
    233233 ideal I=imap(W1,I);
    234234 ideal J=imap(W1,J);
    235  execute("ring qq=0,("+varstr(S)+"),dp;");
     235 ring qq = create_ring(0, "("+varstr(S)+")", "dp");
    236236 ideal I=imap(S,I);
    237237 ideal J=imap(S,J);
     
    315315 if((u^2)==0)
    316316 {
    317   execute("ring A=(real,e-1),("+varstr(S)+",I),ds;");
     317  ring A = create_ring("(real,e-1)", "("+varstr(S)+",I)", "ds");
    318318  ideal II=imap(S,J);
    319319  list rw=imap(S,rw);
     
    332332 {
    333333  int d=dim(std(J));
    334   execute("ring R=(complex,e-1,I),("+varstr(S)+"),ds;");
     334  ring R = create_ring("(complex,e-1,I)", "("+varstr(S)+")", "ds");
    335335  list w=imap(S,w);
    336336  ideal II=imap(S,J);
     
    355355  if(tt==d)
    356356  {
    357    execute("ring A=(complex,e,I),("+varstr(S)+"),dp;");
     357   ring A = create_ring("(complex,e,I)", "("+varstr(S)+")", "dp");
    358358   t=tt;
    359359  }
    360360  else
    361361  {
    362    execute("ring RR=(real,e-2),("+varstr(S)+",I),dp;");
     362   ring RR = create_ring("(real,e-2)", "("+varstr(S)+",I)", "dp");
    363363   ideal II=imap(S,J);
    364364   list rw=imap(S,rw);
     
    398398    setring M;
    399399    sz1=size(SOL);
    400     execute("ring RRRQ=(real,e-1),("+varstr(S)+",I),dp;");
     400    ring RRRQ = create_ring("(real,e-1)", "("+varstr(S)+",I)", "dp");
    401401    ideal HH=imap(RR,HH);
    402402    if(dim(std(HH))==0)
     
    413413   if(sz1==sz2)
    414414   {
    415     execute("ring A=(complex,e,I),("+varstr(S)+"),dp;");
     415    ring A = create_ring("(complex,e,I)", "("+varstr(S)+")", "dp");
    416416    t=d;
    417417   }
    418418   else
    419419   {
    420     execute("ring RQ=(real,e-1),("+varstr(S)+"),dp;");
     420    ring RQ = create_ring("(real,e-1)", "("+varstr(S)+")", "dp");
    421421    ideal II=imap(S,J);
    422422    def RW=WitSet(II);
     
    448448        if((ni+nr)<1/10^(2*e-3))
    449449        {
    450          execute("ring A=(complex,e,I),("+varstr(S)+"),dp;");
     450         ring A = create_ring("(complex,e,I)", "("+varstr(S)+")", "dp");
    451451         list W(ii)=imap(RW,W(ii));
    452452         t=0;
     
    459459      {
    460460       def SS=Singular2bertini(W(ii));
    461        execute("ring D=(complex,e,I),("+varstr(S)+",s,gamma),dp;");
     461       ring D = create_ring("(complex,e,I)", "("+varstr(S)+",s,gamma)", "dp");
    462462       string nonsin;
    463463       ideal H,L;
     
    504504         if(tr<=1/10^(2*e-3))
    505505         {
    506           execute("ring A=(complex,e,I),("+varstr(S)+"),dp;");
     506          ring A = create_ring("(complex,e,I)", "("+varstr(S)+")", "dp");
    507507          t=ii;
    508508          ii=d+1;
  • Singular/LIB/numerDecom.lib

    r3f94cb r3d5b277  
    349349   if((n-rn)!=dd)
    350350   {
    351     execute("ring R=0,("+varstr(S)+",z(1..dd)),dp;");
     351    list l2 = ringlist(S)[2];
     352    for (int ii = 1; ii <= dd; ii++)
     353    {
     354     l2[size(l2)+1] = "z("+string(ii)+")";
     355    }
     356    ring R = create_ring(0, l2, "dp");
    352357    ideal I=imap(rs,I);
    353358    ideal H(0..n),L,LL,L(1..dd),LL(1..dd),h(1..dd),N(0..dd);
     
    483488     {
    484489      int w(q-1)=0;
    485       execute("ring D(q)=(0,s,gamma),("+varstr(S)+",z(1..q)),dp;");
     490      list l2 = ringlist(S)[2];
     491      for (int ii = 1; ii <= q; ii++)
     492      {
     493       l2[size(l2)+1] = "z("+string(ii)+")";
     494      }
     495      ring D(q) = create_ring("(0,s,gamma)", l2, "dp");
    486496      string nonsin(q),stnonsin(q);
    487497      ideal H(1..q);
     
    579589         for(qq=q-1;qq>=1;qq--)
    580590         {
    581           execute("ring T(qq)=(complex,16,I),("+varstr(S)+",z(1..qq)),dp;");
     591          list l2 = ringlist(S)[2];
     592          for (int ii = 1; ii <= qq; ii++)
     593          {
     594           l2[size(l2)+1] = "z("+string(ii)+")";
     595          }
     596          ring T(qq) = create_ring("(complex,16,I)", l2, "dp");
    582597          list W(qq-1)=var(1);
    583598         }
     
    591606       {
    592607        int w(qq-1);
    593         execute("ring T(qq)=(complex,16,I),("+varstr(S)+",z(1..qq)),dp;");
     608        list l2 = ringlist(S)[2];
     609        for (int ii = 1; ii <= qq; ii++)
     610        {
     611         l2[size(l2)+1] = "z("+string(ii)+")";
     612        }
     613        ring T(qq) = create_ring("(complex,16,I)", l2, "dp");
    594614        list W(qq-1)=var(1);
    595615       }
     
    600620      for(qq=q;qq>=1;qq--)
    601621      {
    602        execute("ring T(qq)=(complex,16,I),("+varstr(S)+",z(1..qq)),dp;");
     622       list l2 = ringlist(S)[2];
     623       for (int ii = 1; ii <= qq; ii++)
     624       {
     625        l2[size(l2)+1] = "z("+string(ii)+")";
     626       }
     627       ring T(qq) = create_ring("(complex,16,I)", l2, "dp");
    603628       list W(qq-1)=var(1);
    604629      }
     
    19511976  export(J(i));
    19521977 }
    1953  execute("ring RR=0,(x(1..n),"+varstr(S)+"),dp;");
     1978 list l2;
     1979 for (int ii = 1; ii <= n; ii++)
     1980 {
     1981  l2[ii] = "x("+string(ii)+")";
     1982 }
     1983 l2 = l2+ringlist(S)[2];
     1984 ring RR = create_ring(0, l2, "dp");
    19541985 for(i=1;i<=d;i++)
    19551986 {
     
    19952026 int zc=size(D(d));
    19962027 export(zc);
    1997  execute("ring DR=0,("+varstr(S)+",x(1..zc)),dp;");
     2028 list l2 = ringlist(S)[2];
     2029 for (int ii = 1; ii <= zc; ii++)
     2030 {
     2031  l2[size(l2)+1] = "x("+string(ii)+")";
     2032 }
     2033 ring DR = create_ring(0, l2, "dp");
    19982034 matrix TT(d)=imap(R,TT(d));
    19992035 ideal I=imap(S,I);
  • Singular/LIB/resolve.lib

    r3f94cb r3d5b277  
    396396            laM=subst(laM,var(templist[4][j]),0);
    397397         }
    398          execute("ring Rnew=("+charstr(basering)+"),("+string(templist[1])+"),dp;");
     398         ring Rnew = create_ring(ringlist(basering)[1], "("+string(templist[1])+")", "dp", "no_minpoly");
    399399         ideal Jnew=imap(R,Jsub);
    400400         ideal eD=imap(R,Esub);
     
    639639         v=N[4];
    640640         for(j=1;j<=size(v);j++){BO[5]=subst(BO[5],var(v[j]),0);}
    641          execute("ring R1=("+charstr(R0)+"),("+newvar+"),dp;");
     641         ring R1 = create_ring(ringlist(R0)[1], "("+newvar+")", "dp", "no_minpoly");
    642642         list BO=imap(R0,BO);
    643643         ideal C=imap(R0,C);
     
    11151115              laM=subst(laM,var(v[j]),0);
    11161116           }
    1117            execute("ring R2=("+charstr(S)+"),("+newvar+"),dp;");
     1117           ring R2 = create_ring(ringlist(S)[1], "("+newvar+")", "dp", "no_minpoly");
    11181118           list BO=imap(S,B);
    11191119           ideal laM=imap(S,laM);
     
    29842984//--- hypersurface is V(@f)
    29852985       @f=Jb[fvec[i]];
    2986        execute("ring R1=("+charstr(R)+"),(@y,"+varstr(R)+"),dp;");
     2986       ring R1 = create_ring(ringlist(R)[1], "(@y,"+varstr(R)+")", "dp", "no_minpoly");
    29872987       poly p=imap(R,@p);
    29882988       poly f=imap(R,@f);
     
    42334233             kill tr,L;
    42344234          }
    4235           execute("ring R1=("+charstr(S)+"),(@z,"+varstr(S)+"),dp;");
     4235          ring R1 = create_ring(ringlist(S)[1], "(@z,"+varstr(S)+")", "dp", "no_minpoly");
    42364236          poly p=imap(S,@p);
    42374237          list BO=imap(S,BO);
     
    48004800      {
    48014801         string newvar=string(N[1]);
    4802          execute("ring R1=("+charstr(R)+"),("+newvar+"),dp;");
     4802         ring R1 = create_ring(ringlist(R)[1], "("+newvar+")", "dp", "no_minpoly");
    48034803         list BO=imap(R,BO);
    48044804         ideal cent=imap(R,cent);
  • Singular/LIB/rinvar.lib

    r3f94cb r3d5b277  
    658658          minPoly = string(minpoly);
    659659        }
    660         execute("ring RA1=0,(" + varstr(basering) + "," + parName + "), lp;");
     660        ring RA1 = create_ring(0, "(" + varstr(basering) + "," + parName + ")", "lp");
    661661        if (minPoly!="0") { execute("ideal mpoly = std(" + minPoly + ");"); }
    662662        ideal I = imap(RIRR,invarsGens);
     
    962962    minPoly = string(minpoly);
    963963  }
    964   execute("ring RA1=0,(" + varstr(basering) + "," + parName + "), lp;");
     964  ring RA1 = create_ring(0, "(" + varstr(basering) + "," + parName + ")", "lp");
    965965  if (minPoly!="0") { execute("ideal mpoly = std(" + minPoly + ");"); }
    966966  ideal Grp = imap(ROBR,Grp);
  • Singular/LIB/sing.lib

    r3f94cb r3d5b277  
    10761076  int ii;
    10771077  def bas = basering;
    1078   execute("ring  @r_locstd
    1079      =("+charstr(bas)+"),(@t@,"+varstr(bas)+"),(dp(1),dp);");
     1078  ring @r_locstd = create_ring(ringlist(bas)[1], "(@t@,"+varstr(bas)+")", "(dp(1),dp)", "no_minpoly");
    10801079  ideal @id = imap(bas,id);
    10811080  ideal @hid = homog(@id,@t@);
  • Singular/LIB/standard.lib

    r3f94cb r3d5b277  
    25722572{
    25732573  string name;
    2574   intvec w;
    25752574  int b1 = find(ordering, "(", 1);
    25762575  if (b1 == 0)   // no parentheses
     
    25792578    if (name == "C" || name == "c")
    25802579    {
    2581       w = intvec(0);
     2580      intvec w = intvec(0);
    25822581    }
    25832582    else
    25842583    {
    2585       w = 1:n_vars;
     2584      intvec w = 1:n_vars;
    25862585    }
    25872586  }
     
    25932592    if (c == 0)
    25942593    {
    2595       w = 1:int(ordering[b1+1, b2-b1-1]);
     2594      if (name == "L")
     2595      {
     2596        int w = int(ordering[b1+1, b2-b1-1]);
     2597      }
     2598      else
     2599      {
     2600        intvec w = 1:int(ordering[b1+1, b2-b1-1]);
     2601      }
    25962602    }
    25972603    else
    25982604    {
    25992605      list W = tuple_to_tokens(ordering[b1, b2-b1+1]);
    2600       w = intvec(int(W[1..size(W)]));
     2606      intvec w = intvec(int(W[1..size(W)]));
    26012607    }
    26022608  }
  • Singular/LIB/tropical.lib

    r3f94cb r3d5b277  
    36443644  CHARAKTERISTIK=CHARAKTERISTIK[1..size(CHARAKTERISTIK)-2];
    36453645  def BASERING=basering;
    3646   execute("ring INITIALRING=("+CHARAKTERISTIK+"),("+varstr(basering)+"),("+ordstr(basering)+");");
     3646  ring INITIALRING = create_ring("("+CHARAKTERISTIK+")", "("+varstr(basering)+")", "("+ordstr(basering)+")");
    36473647  list l=solve(imap(BASERING,i));
    36483648  l;
     
    55515551      setring LIFTRing;
    55525552      poly mp=minpoly;
    5553       execute("ring TESTRing=("+charstr(LIFTRing)+"),("+varstr(BASERING)+"),dp;");
     5553      ring TESTRing = create_ring(ringlist(LIFTRing)[1], "("+varstr(BASERING)+")", "dp", "no_minpoly");
    55545554      minpoly=number(imap(LIFTRing,mp));
    55555555      ideal i=imap(BASERING,i);
     
    59395939        else
    59405940        {
    5941           execute("ring PARARing=("+charstr(basering)+"),t,ls;");
     5941          ring PARARing = create_ring(ringlist(basering)[1], "t", "ls", "no_minpoly");
    59425942        }
    59435943        ideal PARA; // will contain the parametrisation
     
    62006200        else
    62016201        {
    6202           execute("ring SATURATERING=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");");
     6202          ring SATURATERING = create_ring(ringlist(basering)[1], "("+varstr(basering)+")", "("+ordstr(basering)+")", "no_minpoly");
    62036203          ideal i=imap(BASERING,i);
    62046204          export(i);
     
    63416341  // - the variable t is superflous,
    63426342  // the variable @a is not if it was already present
    6343   execute("ring INITIALRING=("+charstr(basering)+"),("+string(variablen)+"),dp;");
     6343  ring INITIALRING = create_ring(ringlist(basering)[1], "("+string(variablen)+")", "dp", "no_minpoly");
    63446344  ideal ini=imap(BASERING,ini);
    63456345  // compute the minimal associated primes of the
     
    63676367      // define the extension ring which contains
    63686368      // the new variable @a, if it is not yet present
    6369       execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+string(imap(BASERING,variablen))+",@a,"+tvar+"),(dp("+string(anzahlvariablen-1)+"),dp(1),lp(1));");
     6369      ring EXTENSIONRING = create_ring(ringlist(BASERING)[1], "("+string(imap(BASERING,variablen))+",@a,"+tvar+")", "(dp("+string(anzahlvariablen-1)+"),dp(1),lp(1))", "no_minpoly");
    63706370      // phi maps x_i to x_i, @a to @a (if present in the ring),
    63716371      // and the additional variable
     
    63786378    else // @a was already present in the BASERING or no
    63796379    { // field extension is necessary
    6380       execute("ring EXTENSIONRING=("+charstr(BASERING)+"),("+varstr(BASERING)+"),("+ordstr(BASERING)+");");
     6380      ring EXTENSIONRING = create_ring(ringlist(BASERING)[1], "("+varstr(BASERING)+")", "("+ordstr(BASERING)+")", "no_minpoly");
    63816381      // phi maps x_i to x_i, @a to @a (if present in the ring),
    63826382      // and the additional variable
     
    72557255{
    72567256  def BASERING=basering;
    7257   execute("ring INTERRING=0,("+varstr(basering)+"),("+ordstr(basering)+");");
     7257  ring INTERRING = create_ring(0, "("+varstr(basering)+")", "("+ordstr(basering)+")");
    72587258  poly n=imap(BASERING,n);
    7259   execute("ring REALRING=(real,50,100),("+varstr(basering)+"),("+ordstr(basering)+");");
     7259  ring REALRING = create_ring("(real,50,100)", "("+varstr(basering)+")", "("+ordstr(basering)+")");
    72607260  map phi=INTERRING,maxideal(1);
    72617261  string s=string(phi(n));
     
    78737873  {
    78747874    def BASERING=basering;
    7875     execute("ring TRING="+string(char(BASERING))+",t,ds;");
     7875    ring TRING = create_ring(string(char(BASERING)), "t", "ds");
    78767876    poly hn=imap(BASERING,hn);
    78777877    poly c4=imap(BASERING,c4);
  • factory/FLINTconvert.cc

    r3f94cb r3d5b277  
    692692  convFactoryPFlintMP(F,f,ctx,N);
    693693  convFactoryPFlintMP(G,g,ctx,N);
    694   nmod_mpoly_init3(res,lF+lG,bits+1,ctx);
     694  nmod_mpoly_init(res,ctx);
    695695  nmod_mpoly_mul(res,f,g,ctx);
    696696  nmod_mpoly_clear(g,ctx);
     
    713713  convFactoryPFlintMP(F,f,ctx,N);
    714714  convFactoryPFlintMP(G,g,ctx,N);
    715   fmpq_mpoly_init3(res,lF+lG,bits+1,ctx);
     715  fmpq_mpoly_init(res,ctx);
    716716  fmpq_mpoly_mul(res,f,g,ctx);
    717717  fmpq_mpoly_clear(g,ctx);
     
    737737  convFactoryPFlintMP(F,f,ctx,N);
    738738  convFactoryPFlintMP(G,g,ctx,N);
    739   nmod_mpoly_init3(res,lf,bits,ctx);
     739  nmod_mpoly_init(res,ctx);
    740740  int ok=nmod_mpoly_gcd(res,f,g,ctx);
    741741  nmod_mpoly_clear(g,ctx);
  • libpolys/polys/flint_mpoly.cc

    rc9824e r3d5b277  
    6565#if 1
    6666// memory allocation is not thread safe; singular polynomials must be constructed in serial
     67
     68/*
     69    We agree the that result of a singular -> fmpq_mpoly conversion is
     70    readonly. This restricts the usage of the result in flint functions to
     71    const arguments. However, the real readonly conversion is currently only
     72    implemented in the threaded conversion below since it requires a scan of
     73    all coefficients anyways. The _fmpq_mpoly_clear_readonly_sing needs to
     74    be provided for a consistent interface in the polynomial operations.
     75*/
     76static void _fmpq_mpoly_clear_readonly_sing(fmpq_mpoly_t a, fmpq_mpoly_ctx_t ctx)
     77{
     78    fmpq_mpoly_clear(a, ctx);
     79}
    6780
    6881void convSingPFlintMP(fmpq_mpoly_t res, fmpq_mpoly_ctx_t ctx, poly p, int lp, const ring r)
     
    186199}
    187200
     201
     202/*
     203    In order that flint may sometimes borrow the large integer coeffs of
     204    polynomials over QQ (borrow means: simply point to the same GMP structs
     205    that singular has already allocated), we define the result of a
     206    singular -> fmpq_mpoly conversion to be readonly. This means we agree
     207    that
     208        - it can only be used as an const argument to a flint function
     209        - singular must not mutate the original coeffs while the readonly object is in use
     210*/
     211
     212static void _fmpq_mpoly_clear_readonly_sing(fmpq_mpoly_t a, fmpq_mpoly_ctx_t ctx)
     213{
     214    if (fmpq_is_one(a->content))
     215    {
     216        if (a->zpoly->alloc > 0)
     217        {
     218            flint_free(a->zpoly->coeffs);
     219            flint_free(a->zpoly->exps);
     220        }
     221
     222        fmpq_clear(a->content);
     223    }
     224    else
     225    {
     226        fmpq_mpoly_clear(a, ctx);
     227    }
     228}
     229
    188230/* singular -> fmpq_mpoly conversion */
    189231
     
    197239    std::vector<poly> markers;
    198240    ring r;
    199 
    200     convert_sing_to_fmpq_mpoly_base(slong num_threads_, fmpq_mpoly_struct * res_,
    201                              const fmpq_mpoly_ctx_struct * ctx_, const ring r_, poly p)
    202       : num_threads(num_threads_),
     241    fmpq_t content;
     242
     243    convert_sing_to_fmpq_mpoly_base(fmpq_mpoly_struct * res_,
     244                     const fmpq_mpoly_ctx_struct * ctx_, const ring r_, poly p)
     245      : num_threads(0),
    203246        res(res_),
    204247        ctx(ctx_),
    205248        r(r_)
    206249    {
     250        fmpq_t c;
     251        fmpq_init(c);
     252        fmpq_init(content);
     253        fmpq_zero(content);
     254
    207255        length = 0;
    208256        while (1)
    209257        {
    210258            if ((length % 4096) == 0)
     259            {
     260                my_convSingNFlintN_QQ(c, number(pGetCoeff(p)));
     261                fmpq_gcd(content, content, c);
    211262                markers.push_back(p);
     263            }
    212264            if (p == NULL)
    213265                return;
     
    215267            pIter(p);
    216268        }
     269
     270        fmpq_clear(c);
     271    }
     272
     273    ~convert_sing_to_fmpq_mpoly_base()
     274    {
     275        fmpq_clear(content);
    217276    }
    218277};
     
    248307
    249308    flint_bitcnt_t required_bits = MPOLY_MIN_BITS;
    250     fmpq_zero(arg->content);
     309    fmpq_set(arg->content, base->content);
    251310
    252311    while (idx < arg->end_idx)
    253312    {
    254         my_convSingNFlintN_QQ(c, number(pGetCoeff(p)));
    255         fmpq_gcd(arg->content, arg->content, c);
     313        number n = number(pGetCoeff(p));
     314
     315        if (fmpq_is_one(arg->content) && (SR_HDL(n)&SR_INT || n->s >= 3))
     316        {
     317            /* content is 1 and n is an integer, nothing to do */
     318        }
     319        else
     320        {
     321            my_convSingNFlintN_QQ(c, n);
     322            fmpq_gcd(arg->content, arg->content, c);
     323        }
    256324
    257325        #if SIZEOF_LONG==8
     
    293361    }
    294362
     363    slong N = mpoly_words_per_exp(base->res->zpoly->bits, base->ctx->zctx->minfo);
     364    fmpz * res_coeffs = base->res->zpoly->coeffs;
     365    ulong * res_exps = base->res->zpoly->exps;
     366    flint_bitcnt_t res_bits = base->res->zpoly->bits;
     367
    295368    while (idx < arg->end_idx)
    296369    {
    297         my_convSingNFlintN_QQ(c, number(pGetCoeff(p)));
    298         FLINT_ASSERT(!fmpq_is_zero(base->res->content));
    299         fmpq_div(t, c, base->res->content);
    300         FLINT_ASSERT(fmpz_is_one(fmpq_denref(t)));
    301 
    302         slong N = mpoly_words_per_exp(base->res->zpoly->bits, base->ctx->zctx->minfo);
    303         fmpz_swap(base->res->zpoly->coeffs + idx, fmpq_numref(t));
     370        if (fmpq_is_one(base->res->content))
     371        {
     372            // borrowing singular integers
     373            // the entry res_coeffs[idx] is junk, we should just overwrite it
     374
     375            number n = number(pGetCoeff(p));
     376
     377            if (SR_HDL(n)&SR_INT)
     378            {
     379                // n is a singular-small integer
     380                res_coeffs[idx] = SR_TO_INT(n);
     381            }
     382            else if (n->s<3)
     383            {
     384                // n is an element of QQ \ ZZ, should not happen
     385                assume(false);
     386            }
     387            else
     388            {
     389                // n is a singular-large integer, n may be flint-small
     390                res_coeffs[idx] = PTR_TO_COEFF(n->z);
     391                if (fmpz_fits_si(res_coeffs + idx))
     392                {
     393                    slong val = fmpz_get_si(res_coeffs + idx);
     394                    if (val >= COEFF_MIN && val <= COEFF_MAX)
     395                        res_coeffs[idx] = val;
     396                }
     397            }
     398        }
     399        else
     400        {
     401            my_convSingNFlintN_QQ(c, number(pGetCoeff(p)));
     402            FLINT_ASSERT(!fmpq_is_zero(base->res->content));
     403            fmpq_div(t, c, base->res->content);
     404            FLINT_ASSERT(fmpz_is_one(fmpq_denref(t)));
     405            fmpz_swap(res_coeffs + idx, fmpq_numref(t));
     406        }
     407
    304408        #if SIZEOF_LONG==8
    305409        p_GetExpVL(p, (int64*)exp, base->r);
    306         mpoly_set_monomial_ui(base->res->zpoly->exps + N*idx, exp, base->res->zpoly->bits, base->ctx->zctx->minfo);
     410        mpoly_set_monomial_ui(res_exps + N*idx, exp, res_bits, base->ctx->zctx->minfo);
    307411        #else
    308412        p_GetExpV(p, (int*)exp, base->r);
    309         mpoly_set_monomial_ui(base->res->zpoly->exps + N*idx, &(exp[1]), base->res->zpoly->bits, base->ctx->minfo);
     413        mpoly_set_monomial_ui(res_exps + N*idx, &(exp[1]), res_bits, base->ctx->minfo);
    310414        #endif
    311415
     
    324428    thread_pool_handle * handles;
    325429    slong num_handles;
    326     slong thread_limit = 1000;
    327 
    328     /* get workers */
     430    slong thread_limit = 1000; // TODO: should be paramter to this function
     431
     432    /* the constructor works out the length of p and sets some markers */
     433    convert_sing_to_fmpq_mpoly_base base(res, ctx, r, p);
     434
     435    /* sensibly limit thread count and get workers */
     436    thread_limit = FLINT_MIN(thread_limit, base.length/1024);
    329437    handles = NULL;
    330438    num_handles = 0;
     
    340448    }
    341449
    342     convert_sing_to_fmpq_mpoly_base base(num_handles + 1, res, ctx, r, p);
    343 
    344450    /* fill in thread division points */
     451    base.num_threads = 1 + num_handles;
    345452    convert_sing_to_fmpq_mpoly_arg * args = new convert_sing_to_fmpq_mpoly_arg[base.num_threads];
    346453    slong cur_idx = 0;
     
    348455    {
    349456        slong next_idx = i + 1 < base.num_threads ? (i + 1)*base.length/base.num_threads : base.length;
     457        FLINT_ASSERT(cur_idx <= base.length);
    350458        next_idx = FLINT_MAX(next_idx, cur_idx);
    351459        next_idx = FLINT_MIN(next_idx, base.length);
     
    367475        required_bits = FLINT_MAX(required_bits, args[i].required_bits);
    368476
    369     /* initialize res with optimal bits */
    370     fmpq_mpoly_init3(res, base.length, mpoly_fix_bits(required_bits, ctx->zctx->minfo), ctx);
    371 
    372477    /* sign of content should match sign of first coeff */
    373     fmpq_zero(base.res->content);
     478    fmpq_t content;
     479    fmpq_init(content);
     480    fmpq_zero(content);
    374481    for (slong i = 0; i < base.num_threads; i++)
    375         fmpq_gcd(base.res->content, base.res->content, args[i].content);
     482        fmpq_gcd(content, content, args[i].content);
    376483    if (p != NULL)
    377484    {
     
    380487        my_convSingNFlintN_QQ(c, number(pGetCoeff(p)));
    381488        if (fmpq_sgn(c) < 0)
    382             fmpq_neg(base.res->content, base.res->content);
     489            fmpq_neg(content, content);
    383490        fmpq_clear(c);
    384491    }
     492
     493    /* initialize res with optimal bits */
     494    required_bits = mpoly_fix_bits(required_bits, ctx->zctx->minfo);
     495    if (fmpq_is_one(content))
     496    {
     497        /* initialize borrowed coeffs */
     498        slong N = mpoly_words_per_exp(required_bits, ctx->zctx->minfo);
     499        slong alloc = base.length;
     500        if (alloc != 0)
     501        {
     502            res->zpoly->coeffs = (fmpz *) flint_malloc(alloc*sizeof(fmpz));
     503            res->zpoly->exps   = (ulong *) flint_malloc(alloc*N*sizeof(ulong));
     504        }
     505        else
     506        {
     507            res->zpoly->coeffs = NULL;
     508            res->zpoly->exps = NULL;
     509        }
     510        res->zpoly->alloc = alloc;
     511        res->zpoly->length = 0;
     512        res->zpoly->bits = required_bits;
     513
     514        fmpq_init(res->content);
     515        fmpq_one(res->content);
     516    }
     517    else
     518    {
     519        /* initialize coeffs that will be created and destroyed */
     520        fmpq_mpoly_init3(res, base.length, required_bits, ctx);
     521        fmpq_swap(res->content, content);
     522    }
     523
     524    fmpq_clear(content);
    385525
    386526    /* fill in res->zpoly */
     
    468608    thread_pool_handle * handles;
    469609    slong num_handles;
    470     slong thread_limit = 1000;
    471 
    472     /* get workers */
     610    slong thread_limit = 1000;// TODO: should be paramter to this function
     611
     612    /* sensibly limit threads and get workers */
     613    thread_limit = FLINT_MIN(thread_limit, f->zpoly->length/1024);
    473614    handles = NULL;
    474615    num_handles = 0;
     
    485626
    486627    convert_fmpq_mpoly_to_sing_base base(num_handles + 1, f, ctx, r);
    487 
    488628    convert_fmpq_mpoly_to_sing_arg * args = new convert_fmpq_mpoly_to_sing_arg[base.num_threads];
    489629    slong cur_idx = 0;
     
    492632        slong next_idx = i + 1 < base.num_threads ? (i + 1)*base.f->zpoly->length/base.num_threads
    493633                                                  : base.f->zpoly->length;
     634        FLINT_ASSERT(cur_idx <= base.f->zpoly->length);
    494635        next_idx = FLINT_MAX(next_idx, cur_idx);
    495636        next_idx = FLINT_MIN(next_idx, base.f->zpoly->length);
     
    542683    ring r;
    543684
    544     convert_sing_to_nmod_mpoly_base(slong num_threads_, nmod_mpoly_struct * res_,
    545                             const nmod_mpoly_ctx_struct * ctx_, const ring r_, poly p)
    546       : num_threads(num_threads_),
     685    convert_sing_to_nmod_mpoly_base(nmod_mpoly_struct * res_,
     686                     const nmod_mpoly_ctx_struct * ctx_, const ring r_, poly p)
     687      : num_threads(0),
    547688        res(res_),
    548689        ctx(ctx_),
     
    624765    }
    625766
     767    slong N = mpoly_words_per_exp(base->res->bits, base->ctx->minfo);
     768    ulong * res_coeffs = base->res->coeffs;
     769    ulong * res_exps = base->res->exps;
     770    flint_bitcnt_t res_bits = base->res->bits;
     771
    626772    while (idx < arg->end_idx)
    627773    {
    628         slong N = mpoly_words_per_exp(base->res->bits, base->ctx->minfo);
    629774        #if SIZEOF_LONG==8
    630775        p_GetExpVL(p, (int64*)exp, base->r);
    631         mpoly_set_monomial_ui(base->res->exps + N*idx, exp, base->res->bits, base->ctx->minfo);
     776        mpoly_set_monomial_ui(res_exps + N*idx, exp, res_bits, base->ctx->minfo);
    632777        #else
    633778        p_GetExpV(p, (int*)exp, base->r);
    634         mpoly_set_monomial_ui(base->res->exps + N*idx, &(exp[1]), base->res->bits, base->ctx->minfo);
     779        mpoly_set_monomial_ui(res_exps + N*idx, &(exp[1]), res_bits, base->ctx->minfo);
    635780        #endif
    636781
    637         base->res->coeffs[idx] = (ulong)(number(pGetCoeff(p)));
     782        res_coeffs[idx] = (ulong)(number(pGetCoeff(p)));
    638783
    639784        pIter(p);
     
    649794    thread_pool_handle * handles;
    650795    slong num_handles;
    651     slong thread_limit = 1000;
    652 
    653     /* get workers */
     796    slong thread_limit = 1000; // TODO: should be paramter to this function
     797
     798    /* the constructor works out the length of p and sets some markers */
     799    convert_sing_to_nmod_mpoly_base base(res, ctx, r, p);
     800
     801    /* sensibly limit thread count and get workers */
     802    thread_limit = FLINT_MIN(thread_limit, base.length/1024);
    654803    handles = NULL;
    655804    num_handles = 0;
     
    665814    }
    666815
    667     convert_sing_to_nmod_mpoly_base base(num_handles + 1, res, ctx, r, p);
    668 
    669816    /* fill in thread division points */
     817    base.num_threads = 1 + num_handles;
    670818    convert_sing_to_nmod_mpoly_arg * args = new convert_sing_to_nmod_mpoly_arg[base.num_threads];
    671819    slong cur_idx = 0;
     
    674822        slong next_idx = i + 1 < base.num_threads ? (i + 1)*base.length/base.num_threads
    675823                                                  : base.length;
     824        FLINT_ASSERT(cur_idx <= base.length);
    676825        next_idx = FLINT_MAX(next_idx, cur_idx);
    677826        next_idx = FLINT_MIN(next_idx, base.length);
     
    777926    thread_pool_handle * handles;
    778927    slong num_handles;
    779     slong thread_limit = 1000;
    780 
    781     /* get workers */
     928    slong thread_limit = 1000; // TODO: should be paramter to this function
     929
     930    /* sensibly limit threads and get workers */
     931    thread_limit = FLINT_MIN(thread_limit, f->length/1024);
    782932    handles = NULL;
    783933    num_handles = 0;
     
    794944
    795945    convert_nmod_mpoly_to_sing_base base(num_handles + 1, f, ctx, r);
    796 
    797946    convert_nmod_mpoly_to_sing_arg * args = new convert_nmod_mpoly_to_sing_arg[base.num_threads];
    798947    slong cur_idx = 0;
     
    801950        slong next_idx = i + 1 < base.num_threads ? (i + 1)*base.f->length/base.num_threads
    802951                                                  : base.f->length;
     952        FLINT_ASSERT(cur_idx <= base.f->length);
    803953        next_idx = FLINT_MAX(next_idx, cur_idx);
    804954        next_idx = FLINT_MIN(next_idx, base.f->length);
     
    845995{
    846996  fmpq_mpoly_t pp,qq,res;
    847   convSingPFlintMP(pp,ctx,p,lp,r);
    848   convSingPFlintMP(qq,ctx,q,lq,r);
     997  convSingPFlintMP(pp,ctx,p,lp,r); // pp read only
     998  convSingPFlintMP(qq,ctx,q,lq,r); // qq read only
    849999  fmpq_mpoly_init(res,ctx);
    8501000  fmpq_mpoly_mul(res,pp,qq,ctx);
    8511001  poly pres=convFlintMPSingP(res,ctx,r);
    8521002  fmpq_mpoly_clear(res,ctx);
    853   fmpq_mpoly_clear(pp,ctx);
    854   fmpq_mpoly_clear(qq,ctx);
     1003  _fmpq_mpoly_clear_readonly_sing(pp,ctx);
     1004  _fmpq_mpoly_clear_readonly_sing(qq,ctx);
    8551005  fmpq_mpoly_ctx_clear(ctx);
    8561006  p_Test(pres,r);
     
    8781028{
    8791029  fmpq_mpoly_t pp,qq,res;
    880   convSingPFlintMP(pp,ctx,p,lp,r);
    881   convSingPFlintMP(qq,ctx,q,lq,r);
     1030  convSingPFlintMP(pp,ctx,p,lp,r); // pp read only
     1031  convSingPFlintMP(qq,ctx,q,lq,r); // qq read only
    8821032  fmpq_mpoly_init(res,ctx);
    8831033  fmpq_mpoly_divides(res,pp,qq,ctx);
    8841034  poly pres = convFlintMPSingP(res,ctx,r);
    8851035  fmpq_mpoly_clear(res,ctx);
    886   fmpq_mpoly_clear(pp,ctx);
    887   fmpq_mpoly_clear(qq,ctx);
     1036  _fmpq_mpoly_clear_readonly_sing(pp,ctx);
     1037  _fmpq_mpoly_clear_readonly_sing(qq,ctx);
    8881038  fmpq_mpoly_ctx_clear(ctx);
    8891039  p_Test(pres,r);
     
    9341084{
    9351085  fmpq_mpoly_t pp,qq,res;
    936   convSingPFlintMP(pp,ctx,p,lp,r);
    937   convSingPFlintMP(qq,ctx,q,lq,r);
     1086  convSingPFlintMP(pp,ctx,p,lp,r); // pp read only
     1087  convSingPFlintMP(qq,ctx,q,lq,r); // qq read only
    9381088  fmpq_mpoly_init(res,ctx);
    9391089  int ok=fmpq_mpoly_gcd(res,pp,qq,ctx);
     
    9591109  }
    9601110  fmpq_mpoly_clear(res,ctx);
    961   fmpq_mpoly_clear(pp,ctx);
    962   fmpq_mpoly_clear(qq,ctx);
     1111  _fmpq_mpoly_clear_readonly_sing(pp,ctx);
     1112  _fmpq_mpoly_clear_readonly_sing(qq,ctx);
    9631113  fmpq_mpoly_ctx_clear(ctx);
    9641114  return pres;
  • libpolys/polys/operations/p_Mult_q.cc

    r3f94cb r3d5b277  
    6767}
    6868
     69static void pqLengthApprox(poly p, poly q, int &lp, int &lq, const int min)
     70{
     71  int l = 0;
     72
     73  do
     74  {
     75    if (p == NULL)
     76    {
     77      lp=l;
     78      lq=l+(q!=NULL);
     79      return;
     80    }
     81    if (q == NULL) /* && p!=NULL */
     82    {
     83      lp=l+1;
     84      lq=l;
     85      return;
     86    }
     87    if (l>min) /* && p,q!=NULL */
     88    {
     89      lp=l; lq=l;
     90      return;
     91    }
     92    pIter(p);
     93    pIter(q);
     94    l++;
     95  }
     96  while (1);
     97}
     98
    6999
    70100static poly _p_Mult_q_Bucket(poly p, const int lp,
     
    290320  poly pt;
    291321
    292   pqLength(p, q, lp, lq, MIN_LENGTH_FACTORY);
     322  // MIN_LENGTH_FACTORY must be >= MIN_LENGTH_FACTORY_QQ, MIN_FLINT_QQ, MIN_FLINT_Zp 20
     323  pqLengthApprox(p, q, lp, lq, MIN_LENGTH_FACTORY);
    293324
    294325  if (lp < lq)
     
    309340    if (pure_polys && rField_is_Q(r) && !convSingRFlintR(ctx,r))
    310341    {
    311       lp=pLength(p);
    312       //printf("mul in flint\n");
    313       poly res=Flint_Mult_MP(p,lp,q,lq,ctx,r);
     342      // lq is a lower bound for the length of p and  q
     343      poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
    314344      if (!copy)
    315345      {
     
    325355    if (pure_polys && rField_is_Zp(r) && !convSingRFlintR(ctx,r))
    326356    {
    327       lp=pLength(p);
    328       //printf("mul in flint\n");
    329       poly res=Flint_Mult_MP(p,lp,q,lq,ctx,r);
     357      // lq is a lower bound for the length of p and  q
     358      poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
    330359      if (!copy)
    331360      {
     
    357386  {
    358387    lp=pLength(p);
    359     assume(lq == pLength(q));
     388    lq=pLength(q);
    360389    return _p_Mult_q_Bucket(p, lp, q, lq, copy, r);
    361390  }
Note: See TracChangeset for help on using the changeset viewer.