Changeset f006a1 in git


Ignore:
Timestamp:
Jul 23, 2019, 4:33:05 PM (4 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
9102bbc549613cd829348b8de22f634afde32b53
Parents:
dcddf9cfa6c64ce8c0dc05e26e136194af70b1e3
git-author:
Karim Abou Zeid <karim23697@gmail.com>2019-07-23 16:33:05+02:00
git-committer:
Karim Abou Zeid <karim23697@gmail.com>2019-07-24 14:54:41+02:00
Message:
Syzygies via LPncGenCount ring variable
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/freealgebra/freealgebra.cc

    rdcddf9c rf006a1  
    55{
    66  const short t1[]={2,RING_CMD,INT_CMD};
    7   if (iiCheckTypes(args,t1,1))
     7  const short t2[]={3,RING_CMD,INT_CMD,INT_CMD};
     8  if (iiCheckTypes(args, t2, 0) || iiCheckTypes(args, t1, 1))
    89  {
    910    ring r=(ring)args->Data();
     
    3233      return TRUE;
    3334    }
    34     ring R=freeAlgebra(r,d);
     35    int ncGenCount = 0;
     36    if (iiCheckTypes(args,t2,0))
     37      ncGenCount = (int)(long) args->next->next->Data();
     38    ring R=freeAlgebra(r,d,ncGenCount);
    3539    res->rtyp=RING_CMD;
    3640    res->data=R;
     
    124128  else return TRUE;
    125129}
    126 
    127 // copied from iparith.cc
    128 // NOTE: they do not set res->rtyp
    129 static BOOLEAN jjSYZYGY(leftv res, leftv v)
    130 {
    131   intvec *ww=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
    132   intvec *w=NULL;
    133   ideal v_id=(ideal)v->Data();
    134   tHomog hom=testHomog;
    135   if (ww!=NULL)
    136   {
    137     if (idTestHomModule(v_id,currRing->qideal,ww))
    138     {
    139       w=ivCopy(ww);
    140       int add_row_shift=w->min_in();
    141       (*w)-=add_row_shift;
    142       hom=isHomog;
    143     }
    144     else
    145     {
    146       //WarnS("wrong weights");
    147       delete ww; ww=NULL;
    148       hom=testHomog;
    149     }
    150   }
    151   else
    152   {
    153     if (v->Typ()==IDEAL_CMD)
    154       if (idHomIdeal(v_id,currRing->qideal))
    155         hom=isHomog;
    156   }
    157   ideal S=idSyzygies(v_id,hom,&w);
    158   res->data = (char *)S;
    159   if (hom==isHomog)
    160   {
    161     int vl=S->rank;
    162     intvec *vv=new intvec(vl);
    163     if ((v->Typ()==IDEAL_CMD)||(ww==NULL))
    164     {
    165       for(int i=0;i<vl;i++)
    166       {
    167         if (v_id->m[i]!=NULL)
    168           (*vv)[i]=p_Deg(v_id->m[i],currRing);
    169       }
    170     }
    171     else
    172     {
    173       p_SetModDeg(ww, currRing);
    174       for(int i=0;i<vl;i++)
    175       {
    176         if (v_id->m[i]!=NULL)
    177           (*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
    178       }
    179       p_SetModDeg(NULL, currRing);
    180     }
    181     if (idTestHomModule(S,currRing->qideal,vv))
    182       atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
    183     else
    184       delete vv;
    185   }
    186   if (w!=NULL) delete w;
    187   return FALSE;
    188 }
    189 
    190 static ring tagRing(ideal I)
    191 {
    192   ring tagRing = currRing;
    193   for (int i = 1; i <= IDELEMS(I); i++)
    194   {
    195     char *varname=(char *)omAlloc(256);
    196     sprintf(varname, "ncgen(%d)", i);
    197     tagRing = rPlusVar(tagRing, varname, 0);
    198     omFreeSize(varname, 256);
    199   }
    200   return tagRing;
    201 }
    202 
    203 static BOOLEAN lpSyzRing(leftv res, leftv v)
    204 {
    205   const short t1[]={1,IDEAL_CMD};
    206   const short t2[]={1,MODUL_CMD};
    207   if (iiCheckTypes(v,t1,1) || iiCheckTypes(v,t2,1))
    208   {
    209     ring origRing = currRing;
    210     currRing = tagRing((ideal)v->Data());
    211 
    212     BOOLEAN error = jjSYZYGY(res, v);
    213     if (error || errorreported) return TRUE;
    214 
    215     ideal syzygy = (ideal) res->data;
    216     for (int i = 0; i < IDELEMS(syzygy); i++)
    217     {
    218       pWrite(syzygy->m[i]);
    219     }
    220 
    221     res->rtyp = RING_CMD;
    222     res->data = currRing;
    223     currRing = origRing;
    224     return FALSE;
    225   }
    226   else return TRUE;
    227 }
    228 
    229 static BOOLEAN lpTagRing(leftv res, leftv v)
    230 {
    231   const short t[]={1,IDEAL_CMD};
    232   if (iiCheckTypes(v,t,1))
    233   {
    234     res->rtyp = RING_CMD;
    235     res->data = tagRing((ideal)v->Data());
    236     return FALSE;
    237   }
    238   else return TRUE;
    239 }
    240130#endif
    241131
     
    248138  p->iiAddCproc("freealgebra.so","lpLmDivides",FALSE,lpLmDivides);
    249139  p->iiAddCproc("freealgebra.so","lpVarAt",FALSE,lpVarAt);
    250   p->iiAddCproc("freealgebra.so","lpSyzRing",FALSE,lpSyzRing);
    251   p->iiAddCproc("freealgebra.so","lpTagRing",FALSE,lpTagRing);
    252140  p->iiAddCproc("freealgebra.so","stest",TRUE,stest);
    253141  p->iiAddCproc("freealgebra.so","btest",TRUE,btest);
  • Singular/iparith.cc

    rdcddf9c rf006a1  
    51535153  ideal v_id=(ideal)v->Data();
    51545154  tHomog hom=testHomog;
     5155#ifdef HAVE_SHIFTBBA
     5156  if (rIsLPRing(currRing))
     5157  {
     5158    if (currRing->LPncGenCount < IDELEMS(v_id))
     5159    {
     5160      Werror("At least %d ncgen variables are needed for this computation.", IDELEMS(v_id));
     5161      return TRUE;
     5162    }
     5163  }
     5164#endif
    51555165  if (ww!=NULL)
    51565166  {
  • kernel/GBEngine/kstd1.cc

    rdcddf9c rf006a1  
    28322832
    28332833  strat->rightGB = rightGB;
    2834   // this relies on the implementation of idPrepare,
    2835   // nonMultiplicativeVars should be the number of rows added in idPrepare() (relevant for syzygies)
    2836   strat->nonMultiplicativeVars = syzComp > 0 ? F->rank - syzComp : 0;
    2837   assume(syzComp <= 0 || strat->nonMultiplicativeVars == IDELEMS(F));
    2838   Print("#tagvars: %d\n", strat->nonMultiplicativeVars);
    28392834
    28402835  if(!TEST_OPT_RETURN_SB)
    28412836    strat->syzComp = syzComp;
    2842   Print("syzComp: %d\n", strat->syzComp);
    28432837  if (TEST_OPT_SB_1)
    28442838    if(!rField_is_Ring(currRing))
  • kernel/GBEngine/kutil.cc

    rdcddf9c rf006a1  
    1227112271* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i]
    1227212272*/
    12273 #define CRITERION_DEBUG
    1227412273void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
    1227512274{
     
    1231312312  /*- computes the lcm(s[i],p) -*/
    1231412313  Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
    12315 
    12316   BOOLEAN lcmHasNonMultiplicativeVar = FALSE;
    12317   int lV = currRing->isLPring;
    12318   int degbound = currRing->N/lV;
    12319   for (int i = 1; i <= degbound; i++)
    12320   {
    12321     for (int j = i*lV; j > (i*lV - strat->nonMultiplicativeVars); j--)
    12322     {
    12323       if (pGetExp(Lp.lcm,j))
    12324       {
    12325         if (lcmHasNonMultiplicativeVar) {
    12326           pLmFree(Lp.lcm);
    12327 #ifdef CRITERION_DEBUG
    12328           /* if (TEST_OPT_DEBUG) PrintS("--- NCGEN crit\n"); */
    12329           if (TEST_OPT_DEBUG) PrintS("--- NCGEN crit\n");
    12330 #endif
    12331           return;
    12332         }
    12333         lcmHasNonMultiplicativeVar = TRUE;
    12334       }
    12335     }
    12336   }
    1233712314
    1233812315  /* the V criterion */
  • kernel/GBEngine/kutil.h

    rdcddf9c rf006a1  
    367367  int cv; // in shift bases: counting V criterion
    368368  /*BOOLEAN*/ char rightGB;
    369   int nonMultiplicativeVars; // number of variables at the end that are non multipicative (needed for syzygies)
    370369  #endif
    371370  /*BOOLEAN*/ char interpt;
  • kernel/ideals.cc

    rdcddf9c rf006a1  
    621621    if (rIsLPRing(currRing))
    622622    {
    623       pSetExp(q, currRing->isLPring - i + j + 1, 1);
     623      pSetExp(q, currRing->isLPring - currRing->LPncGenCount + j + 1, 1);
    624624      p_Setm(q, currRing);
    625625    }
  • libpolys/polys/monomials/ring.cc

    rdcddf9c rf006a1  
    432432  if (rIsLPRing(r))
    433433  {
    434     Print("\n// letterplace ring (block size %d)",r->isLPring);
     434    Print("\n// letterplace ring (block size %d, ncgen count %d)",r->isLPring, r->LPncGenCount);
    435435  }
    436436#endif
     
    13931393#ifdef HAVE_SHIFTBBA
    13941394  res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
     1395  res->LPncGenCount=r->LPncGenCount;
    13951396#endif
    13961397
     
    15221523#ifdef HAVE_SHIFTBBA
    15231524  res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
     1525  res->LPncGenCount=r->LPncGenCount;
    15241526#endif
    15251527
     
    16671669  #ifdef HAVE_SHIFTBBA
    16681670  if (r1->isLPring!=r2->isLPring) return FALSE;
     1671  if (r1->LPncGenCount!=r2->LPncGenCount) return FALSE;
    16691672  #endif
    16701673
  • libpolys/polys/monomials/ring.h

    rdcddf9c rf006a1  
    312312#ifdef HAVE_SHIFTBBA
    313313  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
     314  short          LPncGenCount;
    314315#endif
    315316
  • libpolys/polys/shiftop.cc

    rdcddf9c rf006a1  
    529529  PrintLn(); WriteLPExpV(m1ExpV, ri);
    530530#endif
     531  assume(_p_mLPNCGenValid(m1ExpV, ri));
    531532}
    532533
     
    564565  PrintLn(); WriteLPExpV(m1ExpV, ri);
    565566#endif
     567  assume(_p_mLPNCGenValid(m1ExpV, ri));
    566568}
    567569
     
    608610  assume(p_FirstVblock(m1,r) <= 1);
    609611  assume(p_FirstVblock(m2,r) <= 1);
     612}
     613
     614BOOLEAN _p_mLPNCGenValid(int *mExpV, const ring r)
     615{
     616  BOOLEAN hasNCGen = FALSE;
     617  int lV = r->isLPring;
     618  int degbound = r->N/lV;
     619  int ncGenCount = r->LPncGenCount;
     620  for (int i = 1; i <= degbound; i++)
     621  {
     622    for (int j = i*lV; j > (i*lV - ncGenCount); j--)
     623    {
     624      if (mExpV[j])
     625      {
     626        if (hasNCGen)
     627        {
     628          return FALSE;
     629        }
     630        hasNCGen = TRUE;
     631      }
     632    }
     633  }
     634  return TRUE;
    610635}
    611636
     
    673698    if (B[j]!=0) break;
    674699  }
    675   /* do not need e anymore */
     700
     701  if (j==0)
     702  {
     703    omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
     704    omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
     705    return 1;
     706  }
     707
     708  if (!_p_mLPNCGenValid(e, r))
     709  {
     710    omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
     711    omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
     712    return 0;
     713  }
     714
    676715  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
    677716
    678   if (j==0) goto ret_true;
    679717//   {
    680718//     /* it is a zero exp vector, which is in V */
     
    688726    {
    689727      omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
    690       return(0);
    691     }
    692   }
    693  ret_true:
     728      return 0;
     729    }
     730  }
     731
    694732  omFreeSize((ADDRESS) B, (b+1)*sizeof(int));
    695   return(1);
     733  return 1;
    696734}
    697735
     
    783821}
    784822
    785 ring freeAlgebra(ring r, int d)
    786 {
     823ring freeAlgebra(ring r, int d, int ncGenCount)
     824{
     825  if (ncGenCount) r = rCopy0(r);
     826  for (int i = 1; i <= ncGenCount; i++)
     827  {
     828    char *varname=(char *)omAlloc(256);
     829    sprintf(varname, "ncgen(%d)", i);
     830    ring save = r;
     831    r = rPlusVar(r, varname, 0);
     832    omFreeSize(varname, 256);
     833    rDelete(save);
     834  }
    787835  ring R=rCopy0(r);
    788836  int p;
     
    795843  R->N=r->N*d;
    796844  R->isLPring=r->N;
     845  R->LPncGenCount=ncGenCount;
    797846  // create R->order
    798847  BOOLEAN has_order_a=FALSE;
     
    883932  R->names=names;
    884933
     934  if (ncGenCount) rDelete(r);
    885935  rComplete(R,TRUE);
    886936  return R;
  • libpolys/polys/shiftop.h

    rdcddf9c rf006a1  
    5555BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r);
    5656
     57BOOLEAN _p_mLPNCGenValid(int *mExpV, const ring r);
     58
    5759poly p_LPVarAt(poly p, int pos, const ring r);
    5860
    5961/// create the letterplace ring corresponding to r up to degree d
    60 ring freeAlgebra(ring r, int d);
     62ring freeAlgebra(ring r, int d, int LPncGenCount = 0);
    6163#endif
    6264#endif
Note: See TracChangeset for help on using the changeset viewer.