Changeset d7bf54 in git


Ignore:
Timestamp:
Feb 25, 2021, 12:17:32 AM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
9336f0e9b8dbb865a06659b123d7a44c48751a4f
Parents:
760bfdc0ba8d9abb693802fe89d96a85aca7286c
Message:
simplify idSect*, idEliminate (via idGroebner)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    r760bfdc rd7bf54  
    62846284
    62856285extern BOOLEAN jjPROC(leftv res, leftv u, leftv v);
    6286 ideal kGroebner(ideal F, ideal Q)
    6287 {
    6288   //test|=Sy_bit(OPT_PROT);
    6289   idhdl save_ringhdl=currRingHdl;
    6290   ideal resid;
    6291   idhdl new_ring=NULL;
    6292   if ((currRingHdl==NULL) || (IDRING(currRingHdl)!=currRing))
    6293   {
    6294     currRingHdl=enterid(" GROEBNERring",0,RING_CMD,&IDROOT,FALSE);
    6295     new_ring=currRingHdl;
    6296     IDRING(currRingHdl)=currRing;
    6297   }
    6298   sleftv v; v.Init(); v.rtyp=IDEAL_CMD; v.data=(char *) F;
    6299   idhdl h=ggetid("groebner");
    6300   sleftv u; u.Init(); u.rtyp=IDHDL; u.data=(char *) h;
    6301             u.name=IDID(h);
    6302 
    6303   sleftv res; res.Init();
    6304   if(jjPROC(&res,&u,&v))
    6305   {
    6306     resid=kStd(F,Q,testHomog,NULL);
    6307   }
    6308   else
    6309   {
    6310     //printf("typ:%d\n",res.rtyp);
    6311     resid=(ideal)(res.data);
    6312   }
    6313   // cleanup GROEBNERring, save_ringhdl, u,v,(res )
    6314   if (new_ring!=NULL)
    6315   {
    6316     idhdl h=IDROOT;
    6317     if (h==new_ring) IDROOT=h->next;
    6318     else
    6319     {
    6320       while ((h!=NULL) &&(h->next!=new_ring)) h=h->next;
    6321       if (h!=NULL) h->next=h->next->next;
    6322     }
    6323     if (h!=NULL) omFreeSize(h,sizeof(*h));
    6324   }
    6325   currRingHdl=save_ringhdl;
    6326   u.CleanUp();
    6327   v.CleanUp();
    6328   return resid;
    6329 }
    63306286
    63316287static void jjINT_S_TO_ID(int n,int *e, leftv res)
  • kernel/ideals.cc

    r760bfdc rd7bf54  
    127127
    128128
    129 ideal idSectWithElim (ideal h1,ideal h2)
     129static ideal idSectWithElim (ideal h1,ideal h2, GbVariant alg)
    130130// does not destroy h1,h2
    131131{
     
    185185  idDelete(&h2);
    186186  // eliminate t:
    187   ideal res=idElimination(h,t);
     187  ideal res=idElimination(h,t,NULL,alg);
    188188  // cleanup
    189189  idDelete(&h);
     
    336336    && (!rIsPluralRing(currRing))
    337337    && ((TEST_V_INTERSECT_ELIM) || (!TEST_V_INTERSECT_SYZ)))
    338       return idSectWithElim(first,second);
     338      return idSectWithElim(first,second,alg);
    339339    else length = 1;
    340340  }
     
    381381  }
    382382  intvec *w=NULL;
    383   if (alg==GbDefault) alg=GbStd;
    384   if (alg==GbStd)
    385   {
    386     if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
    387     temp1 = kStd(temp,currRing->qideal,testHomog,&w,NULL,length);
    388     if (w!=NULL) delete w;
    389     idDelete(&temp);
    390   }
    391   else if (alg==GbSlimgb)
    392   {
    393     if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
    394     temp1 = t_rep_gb(currRing, temp, temp->rank);
    395     idDelete(&temp);
    396   }
    397   else if (alg==GbGroebner)
    398   {
    399     if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
    400     BOOLEAN err;
    401     temp1=(ideal)iiCallLibProc1("groebner",temp,MODUL_CMD,err);
    402     if (err)
    403     {
    404       Werror("error %d in >>groebner<<",err);
    405       temp1=idInit(1,1);
    406     }
    407   }
    408   else if (alg==GbModstd)
    409   {
    410     if (TEST_OPT_PROT) { PrintS("modStd:"); mflush(); }
    411     BOOLEAN err;
    412     void *args[]={temp,(void*)1,NULL};
    413     int arg_t[]={MODUL_CMD,INT_CMD,0};
    414     leftv temp0=ii_CallLibProcM("modStd",args,arg_t,currRing,err);
    415     temp1=(ideal)temp0->data;
    416     omFreeBin((ADDRESS)temp0,sleftv_bin);
    417     if (err)
    418     {
    419       Werror("error %d in >>modStd<<",err);
    420       temp1=idInit(1,1);
    421     }
    422   }
    423   else if (alg==GbStdSat)
    424   {
    425     if (TEST_OPT_PROT) { PrintS("std:sat:"); mflush(); }
    426     BOOLEAN err;
    427     // search for 2nd block of vars
    428     int i=0;
    429     int block=-1;
    430     loop
    431     {
    432       if ((currRing->order[i]!=ringorder_c)
    433       && (currRing->order[i]!=ringorder_C)
    434       && (currRing->order[i]!=ringorder_s))
    435       {
    436         if (currRing->order[i]==0) { err=TRUE;break;}
    437         block++;
    438         if (block==1) { block=i; break;}
    439       }
    440       i++;
    441     }
    442     if (block>0)
    443     {
    444       if (TEST_OPT_PROT)
    445       {
    446         Print("sat(%d..%d)\n",currRing->block0[block],currRing->block1[block]);
    447         mflush();
    448       }
    449       ideal v=idInit(currRing->block1[block]-currRing->block0[block]+1,1);
    450       for(i=currRing->block0[block];i<=currRing->block1[block];i++)
    451       {
    452         v->m[i-currRing->block0[block]]=pOne();
    453         pSetExp(v->m[i-currRing->block0[block]],i,1);
    454         pSetm(v->m[i-currRing->block0[block]]);
    455       }
    456       void *args[]={temp,v,NULL};
    457       int arg_t[]={MODUL_CMD,IDEAL_CMD,0};
    458       leftv temp0=ii_CallLibProcM("satstd",args,arg_t,currRing,err);
    459       temp1=(ideal)temp0->data;
    460       omFreeBin((ADDRESS)temp0, sleftv_bin);
    461     }
    462     if (err)
    463     {
    464       Werror("error %d in >>satstd<<",err);
    465       temp1=idInit(1,1);
    466     }
    467   }
     383
     384  if ((alg!=GbDefault)
     385  && (alg!=GbGroebner)
     386  && (alg!=GbModstd)
     387  && (alg!=GbSlimgb)
     388  && (alg!=GbStd))
     389  {
     390    WarnS("wrong algorithm for GB");
     391    alg=GbDefault;
     392  }
     393  temp1=idGroebner(temp,length,alg);
    468394
    469395  if(syz_ring!=orig_ring)
     
    523449     return temp1;
    524450  }
    525   else //temp1=kInterRed(result,currRing->qideal);
    526     return result;
     451  //else
     452  //  temp1=kInterRed(result,currRing->qideal);
     453  return result;
    527454}
    528455
     
    607534  }
    608535  /* std computation --------------------------------------------*/
    609   if (alg==GbDefault) alg=GbStd;
    610   if (alg==GbStd)
    611   {
    612     if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
    613     tempstd = kStd(bigmat,currRing->qideal,testHomog,&w,NULL,syzComp);
    614     if (w!=NULL) delete w;
    615     idDelete(&bigmat);
    616   }
    617   else if (alg==GbSlimgb)
    618   {
    619     if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
    620     tempstd = t_rep_gb(currRing, bigmat, syzComp);
    621     idDelete(&bigmat);
    622   }
    623   else if (alg==GbGroebner)
    624   {
    625     if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
    626     BOOLEAN err;
    627     tempstd=(ideal)iiCallLibProc1("groebner",bigmat,MODUL_CMD,err);
    628     if (err)
    629     {
    630       Werror("error %d in >>groebner<<",err);
    631       tempstd=idInit(1,1);
    632     }
    633   }
    634 //  else if (alg==GbModstd): requires ideal, not module
    635 //  {
    636 //    if (TEST_OPT_PROT) { PrintS("modstd:"); mflush(); }
    637 //    BOOLEAN err;
    638 //    tempstd=(ideal)iiCallLibProc1("modStd",bigmat,MODUL_CMD,err);
    639 //    if (err)
    640 //    {
    641 //      Werror("error %d in >>modStd<<",err);
    642 //      tempstd=idInit(1,1);
    643 //    }
    644 //  }
    645   //else if (alg==GbSba): requires order C,...
    646   //{
    647   //  if (TEST_OPT_PROT) { PrintS("sba:"); mflush(); }
    648   //  tempstd = kSba(bigmat,currRing->qideal,hom,w,1,0,NULL,syzComp);
    649   //  idDelete(&bigmat);
    650   //}
    651   else
    652   {
    653     tempstd=idInit(1,1);
    654     Werror("wrong algorithm %d for SB",(int)alg);
    655   }
     536  if ((alg!=GbDefault)
     537  && (alg!=GbGroebner)
     538  && (alg!=GbModstd)
     539  && (alg!=GbSlimgb)
     540  && (alg!=GbStd))
     541  {
     542    WarnS("wrong algorithm for GB");
     543    alg=GbDefault;
     544  }
     545  tempstd=idGroebner(bigmat,syzComp,alg);
    656546
    657547  if(syz_ring!=orig_ring)
     
    19151805    h=s;
    19161806  }
    1917   // compute kStd
    1918 #if 1
    1919   //rWrite(tmpR);PrintLn();
    1920   //BITSET save1;
    1921   //SI_SAVE_OPT1(save1);
    1922   //si_opt_1 |=1;
    1923   //Print("h: %d gen, rk=%d\n",IDELEMS(h),h->rank);
    1924   //extern char * showOption();
    1925   //Print("%s\n",showOption());
    1926   if (alg==GbDefault) alg=GbStd;
    1927   if (alg==GbStd)
    1928   {
    1929     if (TEST_OPT_PROT) { PrintS("std:"); mflush(); }
    1930     hh = kStd(h,NULL,hom,&w,hilb);
    1931   }
    1932   else if (alg==GbSlimgb)
    1933   {
    1934     if (TEST_OPT_PROT) { PrintS("slimgb:"); mflush(); }
    1935     hh = t_rep_gb(currRing, h, 0);
    1936   }
    1937   else if (alg==GbGroebner)
    1938   {
    1939     if (TEST_OPT_PROT) { PrintS("groebner:"); mflush(); }
    1940     BOOLEAN err;
    1941     hh=(ideal)iiCallLibProc1("groebner",idCopy(h),MODUL_CMD,err);
    1942     if (err)
    1943     {
    1944       Werror("error %d in >>groebner<<",err);
    1945       hh=idInit(1,1);
    1946     }
    1947   }
    1948   else if (alg==GbModstd)
    1949   {
    1950     if (TEST_OPT_PROT) { PrintS("modstd:"); mflush(); }
    1951     BOOLEAN err;
    1952     void *args[]={idCopy(h),(void*)1,NULL};
    1953     int arg_t[]={IDEAL_CMD,INT_CMD,0};
    1954     leftv temp0=ii_CallLibProcM("modStd",args,arg_t,currRing,err);
    1955     hh=(ideal)temp0->data;
    1956     omFreeBin((ADDRESS)temp0,sleftv_bin);
    1957     if (err)
    1958     {
    1959       Werror("error %d in >>modStd<<",err);
    1960       hh=idInit(1,1);
    1961     }
    1962   }
    1963   else if (alg==GbSba)
    1964   {
    1965     if (TEST_OPT_PROT) { PrintS("sba:"); mflush(); }
    1966     hh = kSba(h,currRing->qideal,hom,&w,1,0,NULL);
    1967   }
    1968   else
    1969   {
    1970     hh=idInit(1,1);
    1971     Werror("wrong algorithm %d for SB",(int)alg);
    1972   }
    1973   //SI_RESTORE_OPT1(save1);
    1974   idDelete(&h);
    1975 #else
    1976   extern ideal kGroebner(ideal F, ideal Q);
    1977   hh=kGroebner(h,NULL);
     1807  // compute GB
     1808#ifdef HAVE_SHIFTBBA
     1809  if (rIsLPRing(currRing)) alg = GbStd;
    19781810#endif
     1811  if ((alg!=GbDefault)
     1812  && (alg!=GbGroebner)
     1813  && (alg!=GbModstd)
     1814  && (alg!=GbSlimgb)
     1815  && (alg!=GbSba)
     1816  && (alg!=GbStd))
     1817  {
     1818    WarnS("wrong algorithm for GB");
     1819    alg=GbDefault;
     1820  }
     1821  hh=idGroebner(h,0,alg,hilb);
    19791822  // go back to the original ring
    19801823  rChangeCurrRing(origR);
Note: See TracChangeset for help on using the changeset viewer.