Changeset cfce45f in git


Ignore:
Timestamp:
Aug 31, 2018, 1:32:41 PM (6 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
de5dbc0c9dbc380f0c1708cae5c481c59c9fdee5
Parents:
72436190c57e0fc29bf8613364fedc842ab8f9506cc0f0e69248967085f5a4a1e494eacbc3065e2d
Message:
Merge branch 'spielwiese' into letterplace_kernel_multiplication
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/freegb.lib

    r6cc0f0 rcfce45f  
    1 /////////////////////////////////////////////////////////////////////////////
    21/////////////////////////////////////////////////////////////////////////////
    32version="version freegb.lib 4.1.1.0 Dec_2017 "; // $Id$
     
    9291    ERROR("uptodeg and lV do not agree on the basering!");
    9392  }
    94   // a kind of dirty hack
    95   list L = ringlist(R);
    96   attrib(L,"maxExp",1);
    97   def @R = ring(L);
    98     // Set letterplace-specific attributes for the output ring!
     93
     94  // Set letterplace-specific attributes for the output ring!
     95  // a kind of dirty hack, getting the ringlist again
     96  list RL = ringlist(R);
     97  attrib(RL, "isLetterplaceRing", lV);
     98  attrib(RL, "maxExp", 1);
     99  def @R = ring(RL);
     100
    99101  attrib(@R, "uptodeg", uptodeg);
    100102  attrib(@R, "isLetterplaceRing", lV);
     
    500502  // assumes of the ring have been checked
    501503  // run the computation - it will test assumes on the ideal
    502   int uptodeg = attrib(save,"uptodeg");
    503   int lV = attrib(save,"isLetterplaceRing");
    504504  dbprint(ppl,"start computing GB");
    505   def J = system("freegb",I,uptodeg,lV);
     505  def J = system("freegb",I);
    506506  dbprint(ppl,"finished computing GB");
    507507  dbprint(ppl-1,"the result is:");
     
    25252525    ERROR("Incomplete Letterplace structure on the basering!");
    25262526  }
    2527   int uptodeg = attrib(basering,"uptodeg");
    2528   int lV = attrib(basering,"isLetterplaceRing");
    2529   return(system("stest",a,i,uptodeg,lV));
     2527  return(system("stest",a,i));
    25302528}
    25312529example
  • Singular/extra.cc

    r6cc0f0 rcfce45f  
    11641164    if (strcmp(sys_cmd, "stest") == 0)
    11651165    {
    1166       const short t[]={4,POLY_CMD,INT_CMD,INT_CMD,INT_CMD};
     1166      const short t[]={2,POLY_CMD,INT_CMD};
    11671167      if (iiCheckTypes(h,t,1))
    11681168      {
     
    11701170        h=h->next;
    11711171        int sh=(int)((long)(h->Data()));
    1172         h=h->next;
    1173         int uptodeg=(int)((long)(h->Data()));
    1174         h=h->next;
    1175         int lVblock=(int)((long)(h->Data()));
    11761172        if (sh<0)
    11771173        {
     
    11791175          return TRUE;
    11801176        }
    1181         int L = pLastVblock(p,lVblock);
    1182         if (L+sh > uptodeg)
     1177        int L = pLastVblock(p);
     1178        if (L+sh > currRing->N/currRing->isLPring)
    11831179        {
    11841180          WerrorS("pLPshift: too big shift requested\n");
    11851181          return TRUE;
    11861182        }
    1187         res->data = p_LPshift(p,sh,uptodeg,lVblock,currRing);
     1183        res->data = p_LPshift(p,sh,currRing);
    11881184        res->rtyp = POLY_CMD;
    11891185        return FALSE;
     
    11971193    if (strcmp(sys_cmd, "btest") == 0)
    11981194    {
    1199       const short t[]={2,POLY_CMD,INT_CMD};
     1195      const short t[]={1,POLY_CMD};
    12001196      if (iiCheckTypes(h,t,1))
    12011197      {
    12021198        poly p=(poly)h->CopyD();
    1203         h=h->next;
    1204         int lV=(int)((long)(h->Data()));
    12051199        res->rtyp = INT_CMD;
    1206         res->data = (void*)(long)pLastVblock(p, lV);
    1207         return FALSE;
    1208       }
    1209       else return TRUE;
    1210     }
    1211     else
    1212   #endif
    1213   /*==================== shrink-test for freeGB  =================*/
    1214   #ifdef HAVE_SHIFTBBA
    1215     if (strcmp(sys_cmd, "shrinktest") == 0)
    1216     {
    1217       const short t[]={2,POLY_CMD,INT_CMD};
    1218       if (iiCheckTypes(h,t,1))
    1219       {
    1220         poly p=(poly)h->Data();
    1221         h=h->next;
    1222         int lV=(int)((long)(h->Data()));
    1223         res->rtyp = POLY_CMD;
    1224         //        res->data = p_mShrink(p, lV, currRing);
    1225         //        kStrategy strat=new skStrategy;
    1226         //        strat->tailRing = currRing;
    1227         res->data = p_Shrink(p, lV, currRing);
     1200        res->data = (void*)(long)pLastVblock(p);
    12281201        return FALSE;
    12291202      }
     
    15041477    if (strcmp(sys_cmd, "freegb") == 0)
    15051478    {
    1506       const short t[]={3,IDEAL_CMD,INT_CMD,INT_CMD};
    1507       const short tM[]={3,MODUL_CMD,INT_CMD,INT_CMD};
     1479      const short t[]={1,IDEAL_CMD};
     1480      const short tM[]={1,MODUL_CMD};
    15081481      if (iiCheckTypes(h,tM,0)
    15091482      || (iiCheckTypes(h,t,0)))
     
    15111484        res->rtyp=h->Typ();
    15121485        ideal I=(ideal)h->CopyD();
    1513         h=h->next;
    1514         int uptodeg=(int)((long)(h->Data()));
    1515         h=h->next;
    1516         int lVblock=(int)((long)(h->Data()));
    1517         res->data = freegb(I,uptodeg,lVblock);
     1486        res->data = freegb(I);
    15181487        if (res->data == NULL)
    15191488        {
     
    15251494      else
    15261495      {
    1527         WerrorS("system(\"freegb\",`ideal/module`,`int`,`int`) expected");
     1496        WerrorS("system(\"freegb\",`ideal/module`) expected");
    15281497        return TRUE;
    15291498      }
  • kernel/GBEngine/kInline.h

    r6cc0f0 rcfce45f  
    3131#include "kernel/polys.h"
    3232
     33#include "kernel/GBEngine/shiftgb.h"
    3334
    3435#define HAVE_TAIL_BIN
  • kernel/GBEngine/kspoly.cc

    r6cc0f0 rcfce45f  
    2020#include "kernel/polys.h"
    2121#endif
     22#include "kernel/GBEngine/shiftgb.h"
    2223
    2324#ifdef KDEBUG
     
    123124  }
    124125
     126  poly lmRight;
     127  if (tailRing->isLPring) {
     128    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     129  }
     130
    125131  // take care of coef buisness
    126132  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
     
    130136    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
    131137    p_SetCoeff(lm, bn, tailRing);
     138    if (tailRing->isLPring) pSetCoeff0(p1, bn); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
    132139    if ((ct == 0) || (ct == 2))
    133140      PR->Tail_Mult_nn(an);
     
    142149
    143150  // and finally,
    144   PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     151  if (tailRing->isLPring) {
     152    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     153  } else {
     154    PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     155  }
    145156  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    146157  PR->LmDeleteAndIter();
    147 
    148   // the following is commented out: shrinking
    149 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    150   if ( (currRing->isLPring) && (!strat->homog) )
    151   {
    152     // assume? h->p in currRing
    153     PR->GetP();
    154     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    155     PR->Clear(); // does the right things
    156     PR->p = qq;
    157     PR->t_p = NULL;
    158     PR->SetShortExpVector();
    159   }
    160 #endif
    161158
    162159  return ret;
     
    400397  }
    401398
     399  poly lmRight;
     400  if (tailRing->isLPring) {
     401    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     402  }
     403
    402404  // take care of coef buisness
    403405  if (! n_IsOne(pGetCoeff(p2), tailRing))
     
    407409    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
    408410    p_SetCoeff(lm, bn, tailRing);
     411    if (tailRing->isLPring) pSetCoeff0(p1, bn); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
    409412    if ((ct == 0) || (ct == 2))
    410413      PR->Tail_Mult_nn(an);
     
    419422
    420423  // and finally,
    421   PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     424  if (tailRing->isLPring) {
     425    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     426  } else {
     427    PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     428  }
    422429  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    423430  PR->LmDeleteAndIter();
    424 
    425   // the following is commented out: shrinking
    426 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    427   if ( (currRing->isLPring) && (!strat->homog) )
    428   {
    429     // assume? h->p in currRing
    430     PR->GetP();
    431     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    432     PR->Clear(); // does the right things
    433     PR->p = qq;
    434     PR->t_p = NULL;
    435     PR->SetShortExpVector();
    436   }
    437 #endif
    438431
    439432#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     
    606599  }
    607600
     601  poly lmRight;
     602  if (tailRing->isLPring) {
     603    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     604  }
     605
    608606  // take care of coef buisness
    609607  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
     
    613611    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
    614612    p_SetCoeff(lm, bn, tailRing);
     613    if (tailRing->isLPring) pSetCoeff0(p1, bn); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
    615614    if ((ct == 0) || (ct == 2))
    616615      PR->Tail_Mult_nn(an);
     
    625624
    626625  // and finally,
    627   PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     626  if (tailRing->isLPring) {
     627    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     628  } else {
     629    PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     630  }
    628631  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    629632  PR->LmDeleteAndIter();
    630 
    631   // the following is commented out: shrinking
    632 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    633   if ( (currRing->isLPring) && (!strat->homog) )
    634   {
    635     // assume? h->p in currRing
    636     PR->GetP();
    637     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    638     PR->Clear(); // does the right things
    639     PR->p = qq;
    640     PR->t_p = NULL;
    641     PR->SetShortExpVector();
    642   }
    643 #endif
    644633
    645634#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     
    844833    }
    845834  }
     835
     836  poly lmRight;
     837  if (tailRing->isLPring) {
     838    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     839  }
     840
    846841  // take care of coef buisness
    847842  if(rField_is_Ring(currRing))
    848843  {
    849844    p_SetCoeff(lm, nDiv(pGetCoeff(lm),pGetCoeff(p2)), tailRing);
     845    if (tailRing->isLPring) pSetCoeff0(p1, pGetCoeff(lm)); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
    850846    if (coef != NULL) *coef = n_Init(1, tailRing->cf);
    851847  }
     
    858854      int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
    859855      p_SetCoeff(lm, bn, tailRing);
     856      if (tailRing->isLPring) pSetCoeff0(p1, bn); // lm doesn't point to p1 anymore, if the coef was a pointer, it has been deleted
    860857      if (((ct == 0) || (ct == 2)))
    861858        PR->Tail_Mult_nn(an);
     
    870867
    871868  // and finally,
    872   PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     869  if (tailRing->isLPring) {
     870    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     871  } else {
     872    PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     873  }
    873874  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    874875  PR->LmDeleteAndIter();
    875876
    876   // the following is commented out: shrinking
    877 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    878   if ( (currRing->isLPring) && (!strat->homog) )
    879   {
    880     // assume? h->p in currRing
    881     PR->GetP();
    882     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    883     PR->Clear(); // does the right things
    884     PR->p = qq;
    885     PR->t_p = NULL;
    886     PR->SetShortExpVector();
    887   }
    888 #endif
    889877#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
    890878  if (TEST_OPT_DEBUG)
     
    947935    k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
    948936
     937  poly m12, m22;
     938  if (tailRing->isLPring)
     939  {
     940    // note: because of the crits, p2 is never shifted
     941    int split = p_mFirstVblock(p1, tailRing);
     942    // TODO: shouldn't we use p1 AND p2 here??
     943    k_SplitFrame(m1, m12, split, tailRing);
     944    k_SplitFrame(m2, m22, split, tailRing);
     945    // manually free the coeffs, because pSetCoeff0 is used in the next step
     946    n_Delete(&(m1->coef), tailRing->cf);
     947    n_Delete(&(m2->coef), tailRing->cf);
     948
     949    a1 = p_LPshift(p_Copy(a1, tailRing), 1 - split, tailRing); // unshift a1
     950  }
     951
    949952  pSetCoeff0(m1, lc2);
    950953  pSetCoeff0(m2, lc1);  // and now, m1 * LT(p1) == m2 * LT(p2)
     
    978981  }
    979982  else
    980     a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
     983    if (tailRing->isLPring) {
     984      // m2*a2*m22
     985      a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
     986    } else {
     987      a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
     988    }
    981989#ifdef HAVE_RINGS
    982990  if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
     
    985993  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
    986994
    987   // get m2*a2 - m1*a1
    988   Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
     995  if (tailRing->isLPring) {
     996    // get m2*a2*m22 - m1*a1*m12
     997    Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing), l1, spNoether);
     998  } else {
     999    // get m2*a2 - m1*a1
     1000    Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
     1001  }
    9891002
    9901003  // Clean-up time
    9911004  Pair->LmDeleteAndIter();
    9921005  p_LmDelete(m1, tailRing);
     1006  if (tailRing->isLPring) {
     1007    p_LmDelete(m12, tailRing);
     1008    p_LmDelete(m22, tailRing);
     1009    // m2 is already deleted
     1010    p_Delete(&a1, tailRing); // a1 is a copy: safe to destroy
     1011  }
    9931012
    9941013  if (co != 0)
     
    10031022    }
    10041023  }
    1005 
    1006   // the following is commented out: shrinking
    1007 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    1008   if (currRing->isLPring)
    1009   {
    1010     // assume? h->p in currRing
    1011     Pair->GetP();
    1012     poly qq = p_Shrink(Pair->p, currRing->isLPring, currRing);
    1013     Pair->Clear(); // does the right things
    1014     Pair->p = qq;
    1015     Pair->t_p = NULL;
    1016     Pair->SetShortExpVector();
    1017   }
    1018 #endif
    1019 
    10201024}
    10211025
     
    10591063    With.Delete();
    10601064
    1061   // the following is commented out: shrinking
    1062 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    1063   if (currRing->isLPring)
    1064   {
    1065     // assume? h->p in currRing
    1066     PR->GetP();
    1067     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    1068     PR->Clear(); // does the right things
    1069     PR->p = qq;
    1070     PR->t_p = NULL;
    1071     PR->SetShortExpVector();
    1072   }
    1073 #endif
    1074 
    10751065  return ret;
    10761066}
     
    11141104  if (Lp == Save)
    11151105    With.Delete();
    1116 
    1117   // the following is commented out: shrinking
    1118 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    1119   if (currRing->isLPring)
    1120   {
    1121     // assume? h->p in currRing
    1122     PR->GetP();
    1123     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    1124     PR->Clear(); // does the right things
    1125     PR->p = qq;
    1126     PR->t_p = NULL;
    1127     PR->SetShortExpVector();
    1128   }
    1129 #endif
    11301106
    11311107  return ret;
  • kernel/GBEngine/kstd1.cc

    r6cc0f0 rcfce45f  
    25652565#ifdef HAVE_SHIFTBBA
    25662566ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
    2567                 int newIdeal, intvec *vw, int uptodeg, int lV)
     2567                int newIdeal, intvec *vw)
    25682568{
    25692569  ideal r;
     
    25972597  if (h==testHomog)
    25982598  {
    2599     if (delete_w)
    2600     {
    2601       temp_w=new intvec((strat->ak)+1);
    2602       w = &temp_w;
    2603     }
    26042599    if (strat->ak == 0)
    26052600    {
     
    26462641    /* global ordering */
    26472642    if (w!=NULL)
    2648       r=bbaShift(F,Q,*w,hilb,strat,uptodeg,lV);
     2643      r=bbaShift(F,Q,*w,hilb,strat);
    26492644    else
    2650       r=bbaShift(F,Q,NULL,hilb,strat,uptodeg,lV);
     2645      r=bbaShift(F,Q,NULL,hilb,strat);
    26512646  }
    26522647#ifdef KDEBUG
  • kernel/GBEngine/kstd1.h

    r6cc0f0 rcfce45f  
    4040
    4141ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
    42                 int newIdeal, intvec *vw, int uptodeg, int lVblock);
     42                int newIdeal, intvec *vw);
    4343
    4444/* the following global data are defined in kutil.cc */
  • kernel/GBEngine/kstd2.cc

    r6cc0f0 rcfce45f  
    40404040
    40414041
    4042 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV)
     4042ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
    40434043{
    40444044  int   red_result = 1;
    40454045  int   olddeg,reduc;
    40464046  int hilbeledeg=1,hilbcount=0,minimcnt=0;
    4047   BOOLEAN withT = TRUE; // very important for shifts
     4047  BOOLEAN withT = TRUE; // currently only T contains the shifts
     4048  BITSET save;
     4049  SI_SAVE_OPT1(save);
    40484050
    40494051  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */
     
    40564058  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
    40574059  /*Shdl=*/initBuchMoraShift(F, Q,strat); /* updateS with no toT, i.e. no init for T */
    4058   updateSShift(strat,uptodeg,lV); /* initializes T */
    4059 
     4060  updateSShift(strat); /* initializes T */
    40604061  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
    40614062  reduc = olddeg = 0;
    4062   strat->lV=lV;
    40634063
    40644064#ifndef NO_BUCKETS
     
    40664066    strat->use_buckets = 1;
    40674067#endif
    4068 
    40694068  // redtailBBa against T for inhomogenous input
    40704069  //  if (!TEST_OPT_OLDSTD)
     
    40794078#endif
    40804079
     4080
     4081#ifdef KDEBUG
     4082  //kDebugPrint(strat);
     4083#endif
    40814084  /* compute------------------------------------------------------- */
    40824085  while (strat->Ll >= 0)
     
    41364139    }
    41374140
    4138     poly qq;
    4139 
    4140     /* here in the nonhomog case we shrink the new spoly */
    4141 
    4142     if ( ! strat->homog)
    4143     {
    4144       strat->P.GetP(strat->lmBin); // because shifts are counted with .p structure
    4145       /* in the nonhomog case we have to shrink the polynomial */
    4146       qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
    4147       if (qq != NULL)
    4148       {
    4149          /* we're here if Shrink is nonzero */
    4150         strat->P.p   =  qq;
    4151         strat->P.t_p =  NULL;
    4152         strat->P.GetP(strat->lmBin);
    4153         // update sev and length
    4154         strat->initEcart(&(strat->P));
    4155         strat->P.sev = pGetShortExpVector(strat->P.p);
    4156 //         strat->P.FDeg = strat->P.pFDeg();
    4157 //         strat->P.length = strat->P.pLDeg();
    4158 //         strat->P.pLength =strat->P.GetpLength(); //pLength(strat->P.p);
    4159       }
    4160       else
    4161       {
    4162          /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
    4163 #ifdef KDEBUG
    4164          if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0\n");}
    4165 #endif
    4166          strat->P.p = NULL;
    4167          strat->P.t_p = NULL;
    4168        }
    4169     }
    4170       /* end shrinking poly in the nonhomog case */
    4171 
    41724141    if (strat->P.p == NULL && strat->P.t_p == NULL)
    41734142    {
     
    41824151      /* reduction of the element chosen from L */
    41834152      red_result = strat->red(&strat->P,strat);
     4153      if (errorreported) break;
    41844154    }
    41854155
     
    41874157    if (red_result == 1)
    41884158    {
     4159      // get the polynomial (canonicalize bucket, make sure P.p is set)
     4160      strat->P.GetP(strat->lmBin);
     4161      // in the homogeneous case FDeg >= pFDeg (sugar/honey)
     4162      // but now, for entering S, T, we reset it
     4163      // in the inhomogeneous case: FDeg == pFDeg
     4164      if (strat->homog) strat->initEcart(&(strat->P));
     4165
    41894166      /* statistic */
    41904167      if (TEST_OPT_PROT) PrintS("s");
    41914168
    4192       // get the polynomial (canonicalize bucket, make sure P.p is set)
    4193       strat->P.GetP(strat->lmBin);
    4194 
    41954169      int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
    41964170
    41974171      // reduce the tail and normalize poly
     4172      // in the ring case we cannot expect LC(f) = 1,
     4173      // therefore we call pCleardenom instead of pNorm
     4174      strat->redTailChange=FALSE;
    41984175      if (TEST_OPT_INTSTRATEGY)
    41994176      {
     
    42034180          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
    42044181          strat->P.pCleardenom();
     4182          if (strat->redTailChange) {
     4183            strat->P.t_p=NULL;
     4184            strat->initEcart(&(strat->P));
     4185          }
    42054186        }
    42064187      }
     
    42084189      {
    42094190        strat->P.pNorm();
    4210         if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     4191        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) {
    42114192          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
    4212       }
    4213 
    4214       // here we must shrink again! and optionally reduce again
    4215       // or build shrink into redtailBba!
     4193          if (strat->redTailChange) {
     4194            strat->P.t_p=NULL;
     4195            strat->initEcart(&(strat->P));
     4196          }
     4197        }
     4198      }
    42164199
    42174200#ifdef KDEBUG
     
    42404223      }
    42414224
    4242     /* here in the nonhomog case we shrink the reduced poly AGAIN */
    4243 
    4244       if ( ! strat->homog)
    4245       {
    4246         strat->P.GetP(strat->lmBin); // because shifts are counted with .p structure
    4247         /* in the nonhomog case we have to shrink the polynomial */
    4248         if (strat->P.p!=NULL)
    4249         {
    4250           qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
    4251           if (qq != NULL)
    4252           {
    4253             /* we're here if Shrink is nonzero */
    4254             strat->P.p   =  qq; // is not set by Delete
    4255             strat->P.t_p =  NULL;
    4256             strat->P.GetP(strat->lmBin);
    4257             // update sev and length
    4258             strat->initEcart(&(strat->P));
    4259             strat->P.sev = pGetShortExpVector(strat->P.p);
    4260           }
    4261           else
    4262           {
    4263             /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
    4264 #ifdef PDEBUG
    4265             if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}
    4266 #endif
    4267             strat->P.p = NULL;
    4268             strat->P.t_p = NULL;
    4269             goto     red_shrink2zero;
    4270           }
    4271         }
    4272         else
    4273         {
    4274           qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink
    4275           if (qq != NULL)
    4276           {
    4277             /* we're here if Shrink is nonzero */
    4278             strat->P.p   =  qq;
    4279             strat->P.t_p =  NULL;
    4280             // update sev and length
    4281             strat->initEcart(&(strat->P));
    4282             strat->P.sev = pGetShortExpVector(strat->P.p);
    4283           }
    4284           else
    4285           {
    4286             /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/
    4287 #ifdef PDEBUG
    4288             if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}
    4289 #endif
    4290             strat->P.p = NULL;
    4291             strat->P.t_p = NULL;
    4292             goto     red_shrink2zero;
    4293           }
    4294         }
    4295       }
    4296       /* end shrinking poly AGAIN in the nonhomog case */
    4297 
    42984225
    42994226      // enter into S, L, and T
    4300       //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
    4301       //        enterT(strat->P, strat); // this was here before Shift stuff
    4302       //enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV); // syntax
    4303       // the default value for atT = -1 as in bba
    4304       /*   strat->P.GetP(); */
    4305       // because shifts are counted with .p structure // done before, but ?
    4306       int atR=strat->tl+1; // enterTShift introduces T[tl+1], T[tl+2]...
    4307                            // with T[tl+1]=P.p
    4308       enterTShift(strat->P,strat,-1,uptodeg, lV);
    4309       enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, atR,uptodeg,lV);
    4310       //      enterpairsShift(vw,strat->sl,strat->P.ecart,pos,strat, strat->tl,uptodeg,lV);
    4311       // posInS only depends on the leading term
    4312       strat->enterS(strat->P, pos, strat, atR);
     4227      if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     4228      {
     4229        enterT(strat->P, strat);
     4230        enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     4231        // posInS only depends on the leading term
     4232        strat->enterS(strat->P, pos, strat, strat->tl);
     4233        enterTShift(strat->P, strat);
     4234      }
    43134235
    43144236      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    43154237//      Print("[%d]",hilbeledeg);
    43164238      kDeleteLcm(&strat->P);
    4317     }
    4318     else
    4319     {
    4320     red_shrink2zero:
    4321       if (strat->P.p1 == NULL && strat->minim > 0)
    4322       {
    4323         p_Delete(&strat->P.p2, currRing, strat->tailRing);
    4324       }
     4239      if (strat->s_poly!=NULL)
     4240      {
     4241        // the only valid entries are: strat->P.p,
     4242        // strat->tailRing (read-only, keep it)
     4243        // (and P->p1, P->p2 (read-only, must set to NULL if P.p is changed)
     4244        if (strat->s_poly(strat))
     4245        {
     4246          // we are called AFTER enterS, i.e. if we change P
     4247          // we have to add it also to S/T
     4248          // and add pairs
     4249          int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
     4250          int atR=strat->tl+1; // enterTShift introduces P.p=T[tl+1], T[tl+2]...
     4251          enterTShift(strat->P,strat,-1);
     4252          enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, atR);
     4253          strat->enterS(strat->P, pos, strat, atR);
     4254        }
     4255      }
     4256    }
     4257    else if (strat->P.p1 == NULL && strat->minim > 0)
     4258    {
     4259      p_Delete(&strat->P.p2, currRing, strat->tailRing);
    43254260    }
    43264261#ifdef KDEBUG
     
    43324267  if (TEST_OPT_DEBUG) messageSets(strat);
    43334268#endif
     4269  /*  shift case: look for elt's in S such that they are divisible by elt in T */
     4270  if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
     4271  {
     4272    for (int k = 0; k <= strat->sl; ++k)
     4273    {
     4274      for (int j = 0; j<=strat->tl; ++j)
     4275      {
     4276        // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
     4277        assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
     4278        assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
     4279        if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
     4280        {
     4281          if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different
     4282            deleteInS(k, strat);
     4283            --k;
     4284            break;
     4285          }
     4286        }
     4287      }
     4288    }
     4289  }
    43344290  /* complete reduction of the standard basis--------- */
    4335   /*  shift case: look for elt's in S such that they are divisible by elt in T */
    4336   //  if (TEST_OPT_SB_1)
    43374291  if (TEST_OPT_REDSB)
    43384292  {
    4339     int k=0;
    4340     int j=-1;
    4341     while(k<=strat->sl)
    4342     {
    4343 //       loop
    4344 //       {
    4345 //         if (j>=k) break;
    4346 //         clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
    4347 //         j++;
    4348 //       }
    4349       LObject Ln (strat->S[k],currRing, strat->tailRing);
    4350       Ln.SetShortExpVector();
    4351       j = kFindDivisibleByInT(strat, &Ln, j+1);
    4352       if (j<0) {  k++; j=-1;}
    4353       else
    4354       {
    4355         if ( pLmCmp(strat->S[k],strat->T[j].p) == 0)
    4356         {
    4357           j = kFindDivisibleByInT(strat, &Ln, j+1);
    4358           if (j<0) {  k++; j=-1;}
    4359           else
    4360           {
    4361             deleteInS(k,strat);
    4362           }
    4363         }
    4364         else
    4365         {
    4366           deleteInS(k,strat);
    4367         }
    4368       }
    4369     }
    4370   }
    4371 
    4372   if (TEST_OPT_REDSB)
    4373   {    completeReduce(strat, TRUE); //shift: withT = TRUE
     4293    completeReduce(strat, TRUE); //shift: withT = TRUE
    43744294    if (strat->completeReduce_retry)
    43754295    {
     
    43844304        int i;
    43854305        for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
     4306        WarnS("reduction with S is not yet supported by Letterplace"); // if this ever happens, we'll know
    43864307        completeReduce(strat);
    43874308      }
     
    44044325//    }
    44054326//  }
    4406   if (TEST_OPT_PROT) messageStat(hilbcount,strat);
     4327  if ((TEST_OPT_PROT) || (TEST_OPT_DEBUG)) messageStat(hilbcount,strat);
     4328  SI_RESTORE_OPT1(save);
     4329  /* postprocessing for GB over Q-rings ------------------*/
    44074330  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     4331
     4332  idTest(strat->Shdl);
     4333
    44084334  return (strat->Shdl);
    44094335}
    44104336
    44114337
    4412 ideal freegb(ideal I, int uptodeg, int lVblock)
     4338ideal freegb(ideal I)
    44134339{
    4414   /* todo main call */
    4415 
    4416   /* assume: ring is prepared, ideal is copied into shifted ring */
    4417   /* uptodeg and lVblock are correct - test them! */
    4418 
    4419   /* check whether the ideal is in V */
    4420 
    4421 //  if (0)
    4422   if (! ideal_isInV(I,lVblock) )
    4423   {
    4424     WerrorS("The input ideal contains incorrectly encoded elements! ");
    4425     return(NULL);
    4426   }
    4427 
    4428   //  kStrategy strat = new skStrategy;
    4429   /* ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV) */
    4430   /* at the moment:
    4431 - no quotient (check)
    4432 - no *w, no *hilb
    4433   */
    4434   /* ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
    4435      int newIdeal, intvec *vw) */
    4436   ideal RS = kStdShift(I,NULL, testHomog, NULL,NULL,0,0,NULL, uptodeg, lVblock);
    4437     //bbaShift(I,NULL, NULL, NULL, strat, uptodeg, lVblock);
    4438   idSkipZeroes(RS);
     4340  if (!currRing->isLPring) {
     4341    WerrorS("freegb only works with Letterplace rings");
     4342    return NULL;
     4343  }
     4344
     4345  assume(ideal_isInV(I, currRing));
     4346  ideal RS = kStdShift(I,NULL, testHomog, NULL,NULL,0,0,NULL);
     4347  idSkipZeroes(RS); // is this even necessary?
     4348  assume(ideal_isInV(RS, currRing));
    44394349  return(RS);
    44404350}
     
    44794389#endif
    44804390    ksReducePoly(h, &(strat->T[j]), strat->kNoetherTail(), NULL, strat);
    4481     if (!h->IsNull())
    4482     {
    4483       poly qq=p_Shrink(h->GetP(),strat->lV,currRing);
    4484       h->p=qq;
    4485       h->t_p=NULL;
    4486     }
    44874391
    44884392#ifdef KDEBUG
  • kernel/GBEngine/kstdfac.cc

    r6cc0f0 rcfce45f  
    229229  s->noetherSet=o->noetherSet;
    230230#ifdef HAVE_SHIFTBBA
    231   s->lV=o->lV;
     231  s->cv=o->cv;
    232232#endif
    233233#ifdef HAVE_PLURAL
  • kernel/GBEngine/kutil.cc

    r724361 rcfce45f  
    882882  if (L->p!=NULL)
    883883  {
    884     nTest(pGetCoeff(L->p));
    885     if ((L->t_p==NULL)&&(pNext(L->p)!=NULL)) p_Test(pNext(L->p),currRing);
     884    if ((L->t_p==NULL)
     885    &&(pNext(L->p)!=NULL)
     886    &&(pGetCoeff(pNext(L->p))!=NULL)) /* !=strat->tail*/
     887    {
     888      p_Test(pNext(L->p),currRing);
     889      nTest(pGetCoeff(L->p));
     890    }
    886891  }
    887892  if (L->t_p!=NULL)
    888893  {
    889     nTest(pGetCoeff(L->t_p));
    890     if (pNext(L->t_p)!=NULL) p_Test(pNext(L->t_p),strat_tailRing);
     894    if ((pNext(L->t_p)!=NULL)
     895    &&(pGetCoeff(pNext(L->t_p))!=NULL)) /* !=strat->tail*/
     896    {
     897      p_Test(pNext(L->t_p),strat_tailRing);
     898      nTest(pGetCoeff(L->t_p));
     899    }
    891900  }
    892901  if ((L->p!=NULL)&&(L->t_p!=NULL)) assume(pGetCoeff(L->p)==pGetCoeff(L->t_p));
  • kernel/GBEngine/kutil.h

    r6cc0f0 rcfce45f  
    9595  /*BOOLEAN*/ char is_special; // true, it is a new special S-poly (e.g. for SCA)
    9696#endif
     97
     98  // letterplace
     99  int shift;
    97100
    98101  // initialization
     
    362365  #endif
    363366  #ifdef HAVE_SHIFTBBA
    364   int lV;
    365367  int cv; // in shift bases: counting V criterion
    366368  #endif
     
    827829poly pCopyL2p(LObject h, kStrategy strat);
    828830
    829 void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
     831void enterTShift(LObject p, kStrategy strat, int atT = -1);
    830832
    831833void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
    832834
    833 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
    834 
    835 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS, int uptodeg, int lV); // ok
    836 
    837 void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
    838 
    839 void updateSShift(kStrategy strat,int uptodeg,int lV);
     835void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR);
     836
     837void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS);
     838
     839void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
     840
     841void updateSShift(kStrategy strat);
    840842
    841843void initBbaShift(kStrategy strat);
     
    845847int redFirstShift (LObject* h,kStrategy strat); // ok
    846848
    847 ideal freegb(ideal I, int uptodeg, int lVblock);
    848 
    849 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV);
     849ideal freegb(ideal I);
     850
     851ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
    850852// test syz strategy: // will be removed soon
    851853extern  int (*test_PosInT)(const TSet T,const int tl,LObject &h);
  • kernel/GBEngine/shiftgb.cc

    r6cc0f0 rcfce45f  
    3535#define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int))
    3636
    37 
    38 /* TODO: write p* stuff as instances of p_* for all the functions */
    39 /* p_* functions are new, p* are old */
    40 
    41 poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r)
     37poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r)
    4238{
    4339  /* assume shift takes place, shifts the poly p by sh */
     
    5551
    5652  poly q   = NULL;
    57   poly s   = p_mLPshift(p_Head(p,r), sh, uptodeg, lV, r); // lm in currRing
     53  poly s   = p_mLPshift(p_Head(p,r), sh, r); // lm in currRing
    5854  /* pNext(s) will be fixed below */
    5955  poly pp = pNext(p);
     
    6157  while (pp != NULL)
    6258  {
    63     poly h=p_mLPshift(p_Head(pp,strat->tailRing),sh,uptodeg,lV,strat->tailRing);
     59    poly h=p_mLPshift(p_Head(pp,strat->tailRing),sh,strat->tailRing);
    6460    pIter(pp);
    6561
     
    7167}
    7268
    73 poly p_LPshift(poly p, int sh, int uptodeg, int lV, const ring r)
     69poly p_LPshift(poly p, int sh, const ring r)
    7470{
    7571  /* assume shift takes place */
     
    7773
    7874  /* assume sh and uptodeg agree TODO check */
    79   assume(sh>=0);
    8075
    8176  if (sh == 0) return(p); /* the zero shift */
     
    8883    pIter(pp);
    8984    pNext(h)=NULL;
    90     h=p_mLPshift(h,sh,uptodeg,lV,r);
     85    h=p_mLPshift(h,sh,r);
    9186    q = p_Add_q(q, h,r);
    9287  }
     
    9489}
    9590
    96 poly p_mLPshift(poly p, int sh, int uptodeg, int lV, const ring r)
     91poly p_mLPshift(poly p, int sh, const ring r)
    9792{
    9893  /* p is a monomial from the ring r */
    9994
    100   if (sh == 0) return(p); /* the zero shift */
    101 
    102   assume(sh>=0);
    103   int L = p_mLastVblock(p,lV,r);
    104   assume(L+sh<=uptodeg);
     95  int lV = r->isLPring;
     96
     97  if (sh == 0 || p == NULL || p_LmIsConstantComp(p,r)) return(p);
     98
     99  int L = p_mLastVblock(p,r);
     100  assume(L+sh>=1);
     101  assume(L+sh<=r->N/lV);
    105102
    106103  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
     
    117114    {
    118115      assume(j + (sh*lV)<=r->N);
     116      assume(j + (sh*lV)>=1);
    119117      s[j + (sh*lV)] = e[j]; /* actually 1 */
    120118    }
     
    130128}
    131129
    132 int p_LastVblockT(poly p, int lV, kStrategy strat, const ring r)
    133 {
    134   /* returns the number of maximal block */
    135   /* appearing among the monomials of p */
    136   /* the 0th block is the 1st one */
    137 
    138   /* p is like TObject: lm in currRing = r, tail in tailRing  */
    139   assume(p_LmCheckIsFromRing(p,r));
    140   assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
    141 
    142   int ans = p_mLastVblock(p, lV, r); // Block of LM
    143   poly q = pNext(p);
    144   int ansnew = 0;
    145   while (q != NULL)
    146   {
    147     ansnew = p_mLastVblock(q, lV, strat->tailRing);
    148     ans       = si_max(ans,ansnew);
    149     pIter(q);
    150   }
    151   /* do not need to delete q */
    152   return(ans);
    153 }
    154 
    155 int p_LastVblock(poly p, int lV, const ring r)
    156 {
    157   /* returns the number of maximal block */
    158   /* appearing among the monomials of p */
    159   /* the 0th block is the 1st one */
     130/* returns the number of maximal block */
     131/* appearing among the monomials of p */
     132/* the 0th block is the 1st one */
     133int p_LastVblock(poly p, const ring r)
     134{
    160135  poly q = p;
    161136  int ans = 0;
    162   int ansnew = 0;
    163137  while (q!=NULL)
    164138  {
    165     ansnew = p_mLastVblock(q, lV, r);
     139    int ansnew = p_mLastVblock(q, r);
    166140    ans    = si_max(ans,ansnew);
    167141    pIter(q);
     
    170144}
    171145
    172 int p_mLastVblock(poly p, int lV, const ring r)
    173 {
    174   /* for a monomial p, returns the number of the last block */
    175   /* where a nonzero exponent is sitting */
    176   if (p_LmIsConstant(p,r))
     146/* for a monomial p, returns the number of the last block */
     147/* where a nonzero exponent is sitting */
     148int p_mLastVblock(poly p, const ring r)
     149{
     150  if (p == NULL || p_LmIsConstantComp(p,r))
    177151  {
    178152    return(0);
    179153  }
     154
     155  int lV = r->isLPring;
    180156  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
    181157  p_GetExpV(p,e,r);
     
    189165}
    190166
    191 int pFirstVblock(poly p, int lV)
    192 {
    193   /* returns the number of maximal block */
    194   /* appearing among the monomials of p */
    195   /* the 0th block is the 1st one */
    196   poly q = p; //p_Copy(p,currRing); /* need it ? */
    197   int ans = 0;
    198   int ansnew = 0;
     167/* returns the number of maximal block */
     168/* appearing among the monomials of p */
     169/* the 0th block is the 1st one */
     170int p_FirstVblock(poly p, const ring r)
     171{
     172  if (p == NULL) {
     173    return 0;
     174  }
     175
     176  poly q = p;
     177  int ans = p_mFirstVblock(q, r);
    199178  while (q!=NULL)
    200179  {
    201     ansnew = pmFirstVblock(q,lV);
    202     ans    = si_min(ans,ansnew);
     180    int ansnew = p_mFirstVblock(q, r);
     181    if (ansnew > 0) { // don't count constants
     182      ans = si_min(ans,ansnew);
     183    }
    203184    pIter(q);
    204185  }
     
    207188}
    208189
    209 int pmFirstVblock(poly p, int lV)
    210 {
    211   if (pIsConstantPoly(p))
    212   {
    213     return(int(0));
    214   }
    215   /* for a monomial p, returns the number of the first block */
    216   /* where a nonzero exponent is sitting */
    217   int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int));
    218   p_GetExpV(p,e,currRing);
     190/* for a monomial p, returns the number of the first block */
     191/* where a nonzero exponent is sitting */
     192int p_mFirstVblock(poly p, const ring r)
     193{
     194  if (p == NULL || p_LmIsConstantComp(p,r))
     195  {
     196    return(0);
     197  }
     198
     199  int lV = r->isLPring;
     200  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
     201  p_GetExpV(p,e,r);
    219202  int j,b;
    220203  j = 1;
    221   while ( (!e[j]) && (j<=currRing->N-1) ) j++;
    222   if (j==currRing->N + 1)
    223   {
    224 #ifdef PDEBUG
    225     PrintS("pmFirstVblock: unexpected zero exponent vector\n");
    226 #endif
    227     return(j);
    228   }
    229   b = (int)(j/lV)+1; /* the number of the block, 1<= N <= currRing->N  */
     204  while ( (!e[j]) && (j<=r->N-1) ) j++;
     205  freeT(e, r->N);
     206  assume(j <= r->N);
     207  b = (int)(j+lV-1)/lV; /* the number of the block, 1<= b <= r->N  */
    230208  return (b);
    231209}
    232210
    233   /* there should be two routines: */
    234   /* 1. test place-squarefreeness: in homog this suffices: isInV */
    235   /* 2. test the presence of a hole -> in the tail??? */
    236 
    237 int isInV(poly p, int lV)
    238 {
     211/* there should be two routines: */
     212/* 1. test place-squarefreeness: in homog this suffices: isInV */
     213/* 2. test the presence of a hole -> in the tail??? */
     214
     215int isInV(poly p, const ring r)
     216{
     217  int lV = r->isLPring;
    239218  /* investigate only the leading monomial of p in currRing */
    240219  if ( pTotaldegree(p)==0 ) return(1);
    241   if (lV <= 0) return(0);
    242220  /* returns 1 iff p is in V */
    243221  /* that is in each block up to a certain one there is only one nonzero exponent */
     
    287265}
    288266
    289 int poly_isInV(poly p, int lV)
    290 {
    291   /* tests whether the whole polynomial p in in V */
     267/* tests whether the whole polynomial p in in V */
     268int poly_isInV(poly p, const ring r)
     269{
    292270  poly q = p;
    293271  while (q!=NULL)
    294272  {
    295     if ( !isInV(q,lV) )
     273    if ( !isInV(q, r) )
    296274    {
    297275      return(0);
     
    302280}
    303281
    304 int ideal_isInV(ideal I, int lV)
    305 {
    306   /* tests whether each polynomial of an ideal I lies in in V */
     282/* tests whether each polynomial of an ideal I lies in in V */
     283int ideal_isInV(ideal I, const ring r)
     284{
    307285  int i;
    308286  int s    = IDELEMS(I)-1;
    309287  for(i = 0; i <= s; i++)
    310288  {
    311     if ( !poly_isInV(I->m[i],lV) )
     289    if ( !poly_isInV(I->m[i], r) )
    312290    {
    313291      return(0);
     
    318296
    319297
    320 int itoInsert(poly p, int uptodeg, int lV, const ring r)
    321 {
    322   /* for poly in lmCR/tailTR presentation */
     298/* for poly in lmCR/tailTR presentation */
     299int itoInsert(poly p, const ring r)
     300{
    323301  /* the below situation (commented out) might happen! */
    324302//   if (r == currRing)
     
    328306//   }
    329307  /* compute the number of insertions */
    330   int i = p_mLastVblock(p, lV, currRing);
     308  int i = p_mLastVblock(p, currRing);
    331309  if (pNext(p) != NULL)
    332310  {
    333     i = si_max(i, p_LastVblock(pNext(p), lV, r) );
     311    i = si_max(i, p_LastVblock(pNext(p), r) );
    334312  }
    335313  //  i = uptodeg  - i +1;
    336   i = uptodeg  - i;
     314  int uptodeg = r->N/r->isLPring;
    337315  //  p_wrp(p,currRing,r); Print("----i:%d",i); PrintLn();
    338   return(i);
    339 }
    340 
    341 poly p_ShrinkT(poly p, int lV, kStrategy strat, const ring r)
    342 //poly p_Shrink(poly p, int uptodeg, int lV, kStrategy strat, const ring r)
    343 {
    344   /* p is like TObject: lm in currRing = r, tail in tailRing  */
    345   /* proc shrinks the poly p in ring r */
    346   /* lV = the length of V = the number of orig vars */
    347   /* check assumes/exceptions */
    348   /* r->N is a multiple of lV */
    349 
    350   if (p==NULL) return(p);
    351 
    352   assume(p_LmCheckIsFromRing(p,r));
    353   assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
    354 
    355   poly q   = NULL;
    356   poly s   = p_mShrink(p, lV, r); // lm in currRing
    357   poly pp = pNext(p);
    358 
    359   while (pp != NULL)
    360   {
    361     //    q = p_Add_q(q, p_mShrink(pp,uptodeg,lV,strat->tailRing),strat->tailRing);
    362     q = p_Add_q(q, p_mShrink(pp,lV,strat->tailRing),strat->tailRing);
    363     pIter(pp);
    364   }
    365   pNext(s) = q;
    366   return(s);
    367 }
    368 
    369 poly p_Shrink(poly p, int lV, const ring r)
    370 {
    371   /* proc shrinks the poly p in ring r */
    372   /* lV = the length of V = the number of orig vars */
    373   /* check assumes/exceptions */
    374   /* r->N is a multiple of lV */
    375 
    376   if (p==NULL) return(p);
    377   assume(p_CheckIsFromRing(p,r));
    378   poly q = NULL;
    379   poly pp = p;
    380 
    381   while (pp != NULL)
    382   {
    383     q = p_Add_q(q, p_mShrink(pp,lV,r),r);
    384     pIter(pp);
    385   }
    386   return(q);
    387 }
    388 
    389 poly p_mShrink(poly p, int lV, const ring r)
    390 {
    391   /* shrinks the monomial p in ring r */
    392   /* lV = the length of V = the number of orig vars */
    393 
    394   /* check assumes/exceptions */
    395   /* r->N is a multiple of lV */
    396 
    397   int *e = (int *)omAlloc0((r->N+1)*sizeof(int));
    398   int  b = (int)((r->N +lV-1)/lV); /* the number of blocks */
    399   //  int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */
    400   int *S = (int *)omAlloc0((r->N+1)*sizeof(int)); /* the shrinked exponent */
    401   p_GetExpV(p,e,r);
    402   int i,j; int cnt = 1; //counter for blocks in S
    403   for (j=1; j<=b; j++)
    404   {
    405     /* we go through all the vars */
    406     /* by blocks in lV vars */
    407     for (i=(j-1)*lV + 1; i<= j*lV; i++)
    408     {
    409       if (e[i]==1)
    410       {
    411          //      B[j] = B[j]+1; // for control in V?
    412          S[(cnt-1)*lV + (i - (j-1)*lV)] = e[i];
    413          /* assuming we are in V, can interrupt here */
    414          cnt++;
    415          //  break; //results in incomplete shrink!
    416          i = j*lV; // manual break under assumption p is in V
    417       }
    418     }
    419   }
    420 #ifdef PDEBUG
    421   //  Print("p_mShrink: cnt = [%d], b = %d\n",cnt,b);
     316  return uptodeg - i;
     317}
     318
     319// splits a frame (e.g. x(1)*y(5)) m1 into m1 and m2 (e.g. m1=x(1) and m2=y(1))
     320// according to p which is inside the frame
     321void k_SplitFrame(poly &m1, poly &m2, int at, const ring r) {
     322  int lV = r->isLPring;
     323
     324  number m1Coeff = pGetCoeff(m1);
     325
     326  int hole = lV * at;
     327  m2 = p_GetExp_k_n(m1, 1, hole, r);
     328  m1 = p_GetExp_k_n(m1, hole, r->N, r);
     329
     330  p_LPshift(m2, 1 - p_mFirstVblock(m2, r), r);
     331  p_SetCoeff(m1, m1Coeff, r);
     332}
     333
    422334#endif
    423   // cnt -1 <= b  must hold!
    424   //  freeT(B, b);
    425   poly s = p_One(r);
    426   p_SetExpV(s,S,r);
    427   freeT(e, r->N);
    428   freeT(S, r->N);
    429   /*  p_Setm(s,r); // done by p_SetExpV */
    430   p_SetComp(s,p_GetComp(p,r),r); // component is preserved
    431   p_SetCoeff(s,n_Copy(p_GetCoeff(p,r),r->cf),r);  // coeff is preserved
    432 #ifdef PDEBUG
    433   //  Print("p_mShrink: from "); p_wrp(p,r); Print(" to "); p_wrp(s,r); PrintLn();
    434 #endif
    435   return(s);
    436 }
    437 
    438 /* shiftgb stuff */
    439 
    440 
    441 /*2
    442  *if the leading term of p
    443  *divides the leading term of some T[i] it will be canceled
    444  */
    445 // static inline void clearSShift (poly p, unsigned long p_sev,int l, int* at, int* k,
    446 //                            kStrategy strat)
    447 // {
    448 //   assume(p_sev == pGetShortExpVector(p));
    449 //   if (!pLmShortDivisibleBy(p,p_sev, strat->T[*at].p, ~ strat->sevT[*at])) return;
    450 //   //  if (l>=strat->lenS[*at]) return;
    451 //   if (TEST_OPT_PROT)
    452 //     PrintS("!");
    453 //   mflush();
    454 //   //pDelete(&strat->S[*at]);
    455 //   deleteInS((*at),strat);
    456 //   (*at)--;
    457 //   (*k)--;
    458 // //  assume(lenS_correct(strat));
    459 // }
    460 
    461 /* remarks: cleanT : just deletion
    462 enlargeT: just reallocation */
    463 
    464 #endif
  • kernel/GBEngine/shiftgb.h

    r6cc0f0 rcfce45f  
    1212#include "polys/nc/nc.h"
    1313
    14 poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r);
    15 int p_LastVblockT(poly p, int lV, kStrategy strat, const ring r);
     14poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r);
    1615
    17 poly p_ShrinkT(poly p, int lV, kStrategy strat, const ring r);
    18 poly p_Shrink(poly p, int lV, const ring r);
    19 poly p_mShrink(poly p, int lV, const ring r);
    20 //poly p_Shrink(poly p, int uptodeg, int lV, kStrategy strat, const ring r);
    21 //poly p_mShrink(poly p, int uptodeg, int lV, const ring r);
     16poly p_LPshift(poly p, int sh, const ring r);
     17poly p_mLPshift(poly p, int sh, const ring r);
    2218
    23 poly p_LPshift(poly p, int sh, int uptodeg, int lV,const ring r);
    24 poly p_mLPshift(poly p, int sh, int uptodeg, int lV,const ring r);
     19int p_mLastVblock(poly p, const ring r);
     20int p_LastVblock(poly p, const ring r);
    2521
    26 int p_mLastVblock(poly p, int lV,const ring r);
    27 int p_LastVblock(poly p, int lV, const ring r);
     22#define pLastVblock(p) p_LastVblock(p,currRing)
     23#define pmLastVblock(p) p_mLastVblock(p,currRing)
    2824
    29 //int pLastVblock(poly p, int lV);
    30 #define pLastVblock(p,lV) p_LastVblock(p,lV,currRing)
    31 //int pmLastVblock(poly p, int lV);
    32 #define pmLastVblock(p,lV) p_mLastVblock(p,lV,currRing)
     25int p_FirstVblock(poly p, const ring r);
     26int p_mFirstVblock(poly p, const ring r);
    3327
    34 int pFirstVblock(poly p, int lV);
    35 int pmFirstVblock(poly p, int lV);
     28#define pFirstVblock(p) p_FirstVblock(p,currRing)
     29#define pmFirstVblock(p) p_mFirstVblock(p,currRing)
    3630
    37 int isInV(poly p, int lV);
    38 int poly_isInV(poly p, int lV);
    39 int ideal_isInV(ideal I, int lV);
     31int isInV(poly p, const ring r);
     32int poly_isInV(poly p, const ring r);
     33int ideal_isInV(ideal I, const ring r);
    4034
    41 int itoInsert(poly p, int uptodeg, int lV, const ring r);
     35int itoInsert(poly p, const ring r);
    4236
     37void k_SplitFrame(poly &m1, poly &m2, int at, const ring r);
    4338#endif
    4439#endif
  • libpolys/coeffs/longrat.cc

    r6cc0f0 rcfce45f  
    16381638#endif
    16391639    }
    1640     #ifdef LDEBUG
     1640#ifdef LDEBUG
    16411641    memset(*a,0,sizeof(**a));
    1642     #endif
     1642#endif
    16431643    FREE_RNUMBER(*a); // omFreeBin((void *) *a, rnumber_bin);
    16441644  }
  • libpolys/polys/Makefile.am

    r6cc0f0 rcfce45f  
    3535        kbuckets.cc sbuckets.cc weight.cc weight0.c simpleideals.cc matpol.cc \
    3636        sparsmat.cc \
     37        shiftop.cc \
    3738        ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} mod_raw.cc \
    3839        ext_fields/algext.cc ext_fields/transext.cc \
     
    4748        kbuckets.h sbuckets.h simpleideals.h weight.h matpol.h \
    4849        sparsmat.h clapsing.h clapconv.h coeffrings.h flintconv.h\
     50        shiftop.h \
    4951        ext_fields/algext.h ext_fields/transext.h mod_raw.h
    5052
  • libpolys/polys/kbuckets.cc

    r6cc0f0 rcfce45f  
    738738  {
    739739    pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
    740     p1=pp_Mult_mm(p,m,r);
     740    p1=r->p_Procs->pp_mm_Mult(p,m,r);
    741741    pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
    742742    l1=pLength(p1);
     
    780780      else
    781781      {
    782         p1 = r->p_Procs->pp_Mult_mm(p1, m, r);
     782        p1 = r->p_Procs->pp_mm_Mult(p1, m, r);
    783783      }
    784784      pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
  • libpolys/polys/templates/p_Procs_Set.h

    r6cc0f0 rcfce45f  
    1616#include "reporter/reporter.h"
    1717#include "misc/auxiliary.h"
     18#include "shiftop.h"
    1819
    1920// extract p_Procs properties from a ring
     
    165166  }
    166167  #endif
    167   _p_procs->p_mm_Mult=_p_procs->p_Mult_mm;
    168   _p_procs->pp_mm_Mult=_p_procs->pp_Mult_mm;
     168  if (r->isLPring) {
     169    _p_procs->pp_Mult_mm = shift_pp_Mult_mm;
     170    _p_procs->p_Mult_mm = shift_p_Mult_mm;
     171    _p_procs->p_mm_Mult = shift_p_mm_Mult;
     172    _p_procs->pp_mm_Mult = shift_pp_mm_Mult;
     173    _p_procs->p_Minus_mm_Mult_qq = shift_p_Minus_mm_Mult_qq;
     174    // Unsupported
     175    _p_procs->pp_Mult_mm_Noether = shift_pp_Mult_mm_Noether_STUB;
     176    _p_procs->pp_Mult_Coeff_mm_DivSelect = shift_pp_Mult_Coeff_mm_DivSelect_STUB;
     177    _p_procs->pp_Mult_Coeff_mm_DivSelectMult = shift_pp_Mult_Coeff_mm_DivSelectMult_STUB;
     178  } else {
     179    _p_procs->p_mm_Mult=_p_procs->p_Mult_mm;
     180    _p_procs->pp_mm_Mult=_p_procs->pp_Mult_mm;
     181  }
    169182  CheckProc(p_Copy);
    170183  CheckProc(p_Delete);
Note: See TracChangeset for help on using the changeset viewer.