Changeset 15ec95 in git


Ignore:
Timestamp:
Mar 9, 2021, 4:04:03 PM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
d83b510f2bf338d33fc2b853187836719b8ebb4d
Parents:
0c14934b1bcece80c9e10550557151c1cd721a6c
Message:
use idExtractG_T_S in idSyzygies
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/ideals.cc

    r0c1493 r15ec95  
    696696}
    697697
    698 /*2
    699 * compute the syzygies of h1 in R/quot,
    700 * weights of components are in w
    701 * if setRegularity, return the regularity in deg
    702 * do not change h1,  w
    703 */
    704 ideal idSyzygies (ideal  h1, tHomog h,intvec **w, BOOLEAN setSyzComp,
    705                   BOOLEAN setRegularity, int *deg, GbVariant alg)
    706 {
    707   ideal s_h1;
    708   int   j, k, length=0,reg;
    709   BOOLEAN isMonomial=TRUE;
    710   int ii, idElemens_h1;
    711 
    712   assume(h1 != NULL);
    713 
    714   idElemens_h1=IDELEMS(h1);
    715 #ifdef PDEBUG
    716   for(ii=0;ii<idElemens_h1 /*IDELEMS(h1)*/;ii++) pTest(h1->m[ii]);
    717 #endif
    718   if (idIs0(h1))
    719   {
    720     ideal result=idFreeModule(idElemens_h1/*IDELEMS(h1)*/);
    721     return result;
    722   }
    723   int slength=(int)id_RankFreeModule(h1,currRing);
    724   k=si_max(1,slength /*id_RankFreeModule(h1)*/);
    725 
    726   assume(currRing != NULL);
    727   ring orig_ring=currRing;
    728   ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
    729   if (setSyzComp) rSetSyzComp(k,syz_ring);
    730 
    731   if (orig_ring != syz_ring)
    732   {
    733     rChangeCurrRing(syz_ring);
    734     s_h1=idrCopyR_NoSort(h1,orig_ring,syz_ring);
    735   }
    736   else
    737   {
    738     s_h1 = h1;
    739   }
    740 
    741   idTest(s_h1);
    742 
    743   BITSET save_opt;
    744   SI_SAVE_OPT1(save_opt);
    745   si_opt_1|=Sy_bit(OPT_REDTAIL_SYZ);
    746 
    747   ideal s_h3=idPrepare(s_h1,NULL,h,k,w,alg); // main (syz) GB computation
    748 
    749   SI_RESTORE_OPT1(save_opt);
    750 
    751   if (s_h3==NULL)
    752   {
    753     if (orig_ring != syz_ring)
    754     {
    755       rChangeCurrRing(orig_ring);
    756       rDelete(syz_ring);
    757     }
    758     return idFreeModule( idElemens_h1 /*IDELEMS(h1)*/);
    759   }
    760 
    761   if (orig_ring != syz_ring)
    762   {
    763     idDelete(&s_h1);
    764     for (j=0; j<IDELEMS(s_h3); j++)
    765     {
    766       if (s_h3->m[j] != NULL)
    767       {
    768         if (p_MinComp(s_h3->m[j],syz_ring) > k)
    769           p_Shift(&s_h3->m[j], -k,syz_ring);
    770         else
    771           p_Delete(&s_h3->m[j],syz_ring);
    772       }
    773     }
    774     idSkipZeroes(s_h3);
    775     s_h3->rank -= k;
    776     rChangeCurrRing(orig_ring);
    777     s_h3 = idrMoveR_NoSort(s_h3, syz_ring, orig_ring);
    778     rDelete(syz_ring);
    779     #ifdef HAVE_PLURAL
    780     if (rIsPluralRing(orig_ring))
    781     {
    782       id_DelMultiples(s_h3,orig_ring);
    783       idSkipZeroes(s_h3);
    784     }
    785     #endif
    786     idTest(s_h3);
    787     return s_h3;
    788   }
    789 
    790   ideal e = idInit(IDELEMS(s_h3), s_h3->rank);
    791 
    792   for (j=IDELEMS(s_h3)-1; j>=0; j--)
    793   {
    794     if (s_h3->m[j] != NULL)
    795     {
    796       if (p_MinComp(s_h3->m[j],syz_ring) <= k)
    797       {
    798         e->m[j] = s_h3->m[j];
    799         isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
    800         p_Delete(&pNext(s_h3->m[j]),syz_ring);
    801         s_h3->m[j] = NULL;
    802       }
    803     }
    804   }
    805 
    806   idSkipZeroes(s_h3);
    807   idSkipZeroes(e);
    808 
    809   if ((deg != NULL)
    810   && (!isMonomial)
    811   && (!TEST_OPT_NOTREGULARITY)
    812   && (setRegularity)
    813   && (h==isHomog)
    814   && (!rIsPluralRing(currRing))
    815   && (!rField_is_Ring(currRing))
    816   )
    817   {
    818     assume(orig_ring==syz_ring);
    819     ring dp_C_ring = rAssure_dp_C(syz_ring); // will do rChangeCurrRing later
    820     if (dp_C_ring != syz_ring)
    821     {
    822       rChangeCurrRing(dp_C_ring);
    823       e = idrMoveR_NoSort(e, syz_ring, dp_C_ring);
    824     }
    825     resolvente res = sySchreyerResolvente(e,-1,&length,TRUE, TRUE);
    826     intvec * dummy = syBetti(res,length,&reg, *w);
    827     *deg = reg+2;
    828     delete dummy;
    829     for (j=0;j<length;j++)
    830     {
    831       if (res[j]!=NULL) idDelete(&(res[j]));
    832     }
    833     omFreeSize((ADDRESS)res,length*sizeof(ideal));
    834     idDelete(&e);
    835     if (dp_C_ring != orig_ring)
    836     {
    837       rChangeCurrRing(orig_ring);
    838       rDelete(dp_C_ring);
    839     }
    840   }
    841   else
    842   {
    843     idDelete(&e);
    844   }
    845   assume(orig_ring==currRing);
    846   idTest(s_h3);
    847   if (currRing->qideal != NULL)
    848   {
    849     ideal ts_h3=kStd(s_h3,currRing->qideal,h,w);
    850     idDelete(&s_h3);
    851     s_h3 = ts_h3;
    852   }
    853   return s_h3;
    854 }
    855 
    856698ideal idExtractG_T_S(ideal s_h3,matrix *T,ideal *S,long syzComp,
    857699    int h1_size,BOOLEAN inputIsIdeal,const ring oring, const ring sring)
     
    955797      (*S)->m[i] = prMoveR_NoSort((*S)->m[i], sring,oring);
    956798    }
     799  }
     800  return s_h3;
     801}
     802
     803/*2
     804* compute the syzygies of h1 in R/quot,
     805* weights of components are in w
     806* if setRegularity, return the regularity in deg
     807* do not change h1,  w
     808*/
     809ideal idSyzygies (ideal  h1, tHomog h,intvec **w, BOOLEAN setSyzComp,
     810                  BOOLEAN setRegularity, int *deg, GbVariant alg)
     811{
     812  ideal s_h1;
     813  int   j, k, length=0,reg;
     814  BOOLEAN isMonomial=TRUE;
     815  int ii, idElemens_h1;
     816
     817  assume(h1 != NULL);
     818
     819  idElemens_h1=IDELEMS(h1);
     820#ifdef PDEBUG
     821  for(ii=0;ii<idElemens_h1 /*IDELEMS(h1)*/;ii++) pTest(h1->m[ii]);
     822#endif
     823  if (idIs0(h1))
     824  {
     825    ideal result=idFreeModule(idElemens_h1/*IDELEMS(h1)*/);
     826    return result;
     827  }
     828  int slength=(int)id_RankFreeModule(h1,currRing);
     829  k=si_max(1,slength /*id_RankFreeModule(h1)*/);
     830
     831  assume(currRing != NULL);
     832  ring orig_ring=currRing;
     833  ring syz_ring=rAssure_SyzComp(orig_ring,TRUE);
     834  if (setSyzComp) rSetSyzComp(k,syz_ring);
     835
     836  if (orig_ring != syz_ring)
     837  {
     838    rChangeCurrRing(syz_ring);
     839    s_h1=idrCopyR_NoSort(h1,orig_ring,syz_ring);
     840  }
     841  else
     842  {
     843    s_h1 = h1;
     844  }
     845
     846  idTest(s_h1);
     847
     848  BITSET save_opt;
     849  SI_SAVE_OPT1(save_opt);
     850  si_opt_1|=Sy_bit(OPT_REDTAIL_SYZ);
     851
     852  ideal s_h3=idPrepare(s_h1,NULL,h,k,w,alg); // main (syz) GB computation
     853
     854  SI_RESTORE_OPT1(save_opt);
     855
     856  if (orig_ring != syz_ring)
     857  {
     858    ideal S=idInit(IDELEMS(s_h3),IDELEMS(h1));
     859    s_h3=idExtractG_T_S(s_h3,NULL,&S,k,IDELEMS(h1),FALSE,orig_ring,syz_ring);
     860    idDelete(&s_h1);
     861    idDelete(&s_h3);
     862    rDelete(syz_ring);
     863    #ifdef HAVE_PLURAL
     864    if (rIsPluralRing(orig_ring))
     865    {
     866      id_DelMultiples(S,orig_ring);
     867    }
     868    #endif
     869    idSkipZeroes(S);
     870    idTest(S);
     871    return S;
     872  }
     873
     874  ideal e = idInit(IDELEMS(s_h3), s_h3->rank);
     875
     876  for (j=IDELEMS(s_h3)-1; j>=0; j--)
     877  {
     878    if (s_h3->m[j] != NULL)
     879    {
     880      if (p_MinComp(s_h3->m[j],syz_ring) <= k)
     881      {
     882        e->m[j] = s_h3->m[j];
     883        isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
     884        p_Delete(&pNext(s_h3->m[j]),syz_ring);
     885        s_h3->m[j] = NULL;
     886      }
     887    }
     888  }
     889
     890  idSkipZeroes(s_h3);
     891  idSkipZeroes(e);
     892
     893  if ((deg != NULL)
     894  && (!isMonomial)
     895  && (!TEST_OPT_NOTREGULARITY)
     896  && (setRegularity)
     897  && (h==isHomog)
     898  && (!rIsPluralRing(currRing))
     899  && (!rField_is_Ring(currRing))
     900  )
     901  {
     902    assume(orig_ring==syz_ring);
     903    ring dp_C_ring = rAssure_dp_C(syz_ring); // will do rChangeCurrRing later
     904    if (dp_C_ring != syz_ring)
     905    {
     906      rChangeCurrRing(dp_C_ring);
     907      e = idrMoveR_NoSort(e, syz_ring, dp_C_ring);
     908    }
     909    resolvente res = sySchreyerResolvente(e,-1,&length,TRUE, TRUE);
     910    intvec * dummy = syBetti(res,length,&reg, *w);
     911    *deg = reg+2;
     912    delete dummy;
     913    for (j=0;j<length;j++)
     914    {
     915      if (res[j]!=NULL) idDelete(&(res[j]));
     916    }
     917    omFreeSize((ADDRESS)res,length*sizeof(ideal));
     918    idDelete(&e);
     919    if (dp_C_ring != orig_ring)
     920    {
     921      rChangeCurrRing(orig_ring);
     922      rDelete(dp_C_ring);
     923    }
     924  }
     925  else
     926  {
     927    idDelete(&e);
     928  }
     929  assume(orig_ring==currRing);
     930  idTest(s_h3);
     931  if (currRing->qideal != NULL)
     932  {
     933    ideal ts_h3=kStd(s_h3,currRing->qideal,h,w);
     934    idDelete(&s_h3);
     935    s_h3 = ts_h3;
    957936  }
    958937  return s_h3;
Note: See TracChangeset for help on using the changeset viewer.