My Project  UNKNOWN_GIT_VERSION
Macros | Functions
gr_kstd2.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "misc/options.h"
#include "misc/intvec.h"
#include "polys/weight.h"
#include "kernel/polys.h"
#include "polys/monomials/ring.h"
#include "polys/nc/gb_hack.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "kernel/ideals.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/khstd.h"
#include "kernel/GBEngine/ratgring.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/nc.h"

Go to the source code of this file.

Macros

#define PLURAL_INTERNAL_DECLARATIONS
 
#define MYTEST   0
 

Functions

int redGrFirst (LObject *h, kStrategy strat)
 
void ratGB_divide_out (poly p)
 
int redGrRatGB (LObject *h, kStrategy strat)
 
void nc_gr_initBba (ideal F, kStrategy strat)
 nc_gr_initBba is needed for sca_gr_bba and gr_bba. More...
 
ideal k_gnc_gr_bba (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
 
ideal k_gnc_gr_mora (const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing)
 

Macro Definition Documentation

◆ MYTEST

#define MYTEST   0

Definition at line 1030 of file gr_kstd2.cc.

◆ PLURAL_INTERNAL_DECLARATIONS

#define PLURAL_INTERNAL_DECLARATIONS

Definition at line 7 of file gr_kstd2.cc.

Function Documentation

◆ k_gnc_gr_bba()

ideal k_gnc_gr_bba ( const ideal  F,
const ideal  Q,
const intvec ,
const intvec ,
kStrategy  strat,
const ring  _currRing 
)

Definition at line 1032 of file gr_kstd2.cc.

1033 {
1034  const ring save = currRing; if( currRing != _currRing ) rChangeCurrRing(_currRing);
1035 
1036 #if MYTEST
1037  PrintS("<gnc_gr_bba>\n");
1038 #endif
1039 
1040 #ifdef HAVE_PLURAL
1041 #if MYTEST
1042  PrintS("currRing: \n");
1043  rWrite(currRing);
1044 #ifdef RDEBUG
1046 #endif
1047 
1048  PrintS("F: \n");
1049  idPrint(F);
1050  PrintS("Q: \n");
1051  idPrint(Q);
1052 #endif
1053 #endif
1054 
1055  assume(currRing->OrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?)
1056 
1057  // intvec *w=NULL;
1058  // intvec *hilb=NULL;
1059  int olddeg,reduc;
1060  int red_result=1;
1061  int /*hilbeledeg=1,*/hilbcount=0/*,minimcnt=0*/;
1062 
1063  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
1064  // initHilbCrit(F,Q,&hilb,strat);
1065  /* in plural we don't need Hilb yet */
1066  nc_gr_initBba(F,strat);
1067  initBuchMoraPos(strat);
1068  if (rIsRatGRing(currRing))
1069  {
1070  strat->posInL=posInL0; // by pCmp of lcm
1071  }
1072  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
1073  /*Shdl=*/initBuchMora(F, Q,strat);
1074  strat->posInT=posInT110;
1075  reduc = olddeg = 0;
1076 
1077  /* compute------------------------------------------------------- */
1078  while (strat->Ll >= 0)
1079  {
1080  if (TEST_OPT_DEBUG) messageSets(strat);
1081 
1082  if (strat->Ll== 0) strat->interpt=TRUE;
1083  if (TEST_OPT_DEGBOUND
1084  && ((strat->honey
1085  && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
1086  || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
1087  {
1088  /*
1089  *stops computation if
1090  * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
1091  *a predefined number Kstd1_deg
1092  */
1093  while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1094  break;
1095  }
1096  /* picks the last element from the lazyset L */
1097  strat->P = strat->L[strat->Ll];
1098  strat->Ll--;
1099  //kTest(strat);
1100 
1101  if (strat->P.p != NULL)
1102  if (pNext(strat->P.p) == strat->tail)
1103  {
1104  /* deletes the short spoly and computes */
1105  pLmFree(strat->P.p);
1106  /* the real one */
1107 // if (ncRingType(currRing)==nc_lie) /* prod crit */
1108 // if(pHasNotCF(strat->P.p1,strat->P.p2))
1109 // {
1110 // strat->cp++;
1111 // /* prod.crit itself in nc_CreateSpoly */
1112 // }
1113 
1114 
1115  if( ! rIsRatGRing(currRing) )
1116  {
1117  strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,currRing);
1118  }
1119 #ifdef HAVE_RATGRING
1120  else
1121  {
1122  /* rational case */
1123  strat->P.p = nc_rat_CreateSpoly(strat->P.p1,strat->P.p2,currRing->real_var_start-1,currRing);
1124  }
1125 #endif
1126 
1127 
1128 #ifdef PDEBUG
1129  p_Test(strat->P.p, currRing);
1130 #endif
1131 
1132 #if MYTEST
1133  if (TEST_OPT_DEBUG)
1134  {
1135  PrintS("p1: "); pWrite(strat->P.p1);
1136  PrintS("p2: "); pWrite(strat->P.p2);
1137  PrintS("SPoly: "); pWrite(strat->P.p);
1138  }
1139 #endif
1140  }
1141 
1142 
1143  if (strat->P.p != NULL)
1144  {
1145  if (TEST_OPT_PROT)
1146  message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
1147  &olddeg,&reduc,strat, red_result);
1148 
1149 #if MYTEST
1150  if (TEST_OPT_DEBUG)
1151  {
1152  PrintS("p1: "); pWrite(strat->P.p1);
1153  PrintS("p2: "); pWrite(strat->P.p2);
1154  PrintS("SPoly before: "); pWrite(strat->P.p);
1155  }
1156 #endif
1157 
1158  /* reduction of the element chosen from L */
1159  strat->red(&strat->P,strat);
1160 
1161 #if MYTEST
1162  if (TEST_OPT_DEBUG)
1163  {
1164  PrintS("red SPoly: "); pWrite(strat->P.p);
1165  }
1166 #endif
1167  }
1168  if (strat->P.p != NULL)
1169  {
1170  if (TEST_OPT_PROT)
1171  {
1172  PrintS("s\n");
1173  }
1174  /* enter P.p into s and L */
1175  {
1176 /* quick unit detection in the rational case */
1177 #ifdef HAVE_RATGRING
1178  if( rIsRatGRing(currRing) )
1179  {
1180  if ( p_LmIsConstantRat(strat->P.p, currRing) )
1181  {
1182 #ifdef PDEBUG
1183  PrintS("unit element detected:");
1184  p_wrp(strat->P.p,currRing);
1185 #endif
1186  p_Delete(&strat->P.p,currRing, strat->tailRing);
1187  strat->P.p = pOne();
1188  }
1189  }
1190 #endif
1191  strat->P.sev=0;
1192  int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart);
1193  {
1195  {
1196  if ((strat->syzComp==0)||(!strat->homog))
1197  {
1198  #ifdef HAVE_RATGRING
1199  if(!rIsRatGRing(currRing))
1200  #endif
1201  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
1202  }
1203 
1204  strat->P.p=p_Cleardenom(strat->P.p, currRing);
1205  }
1206  else
1207  {
1208  pNorm(strat->P.p);
1209  if ((strat->syzComp==0)||(!strat->homog))
1210  {
1211  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
1212  }
1213  }
1214  if (TEST_OPT_DEBUG)
1215  {
1216  PrintS("new s:"); wrp(strat->P.p);
1217  PrintLn();
1218 #if MYTEST
1219  PrintS("s: "); pWrite(strat->P.p);
1220 #endif
1221 
1222  }
1223  // kTest(strat);
1224  //
1225  enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
1226 
1227  if (strat->sl==-1) pos=0;
1228  else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
1229 
1230  strat->enterS(strat->P,pos,strat,-1);
1231  }
1232 // if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
1233  }
1234  kDeleteLcm(&strat->P);
1235  }
1236  //kTest(strat);
1237  }
1238  if (TEST_OPT_DEBUG) messageSets(strat);
1239 
1240  /* complete reduction of the standard basis--------- */
1241  if (TEST_OPT_SB_1)
1242  {
1243  int k=1;
1244  int j;
1245  while(k<=strat->sl)
1246  {
1247  j=0;
1248  loop
1249  {
1250  if (j>=k) break;
1251  clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
1252  j++;
1253  }
1254  k++;
1255  }
1256  }
1257 
1258  if (TEST_OPT_REDSB)
1259  completeReduce(strat);
1260  /* release temp data-------------------------------- */
1261  exitBuchMora(strat);
1262 // if (TEST_OPT_WEIGHTM)
1263 // {
1264 // currRing->pFDeg=pFDegOld;
1265 // currRing->pLDeg=pLDegOld;
1266 // if (ecartWeights)
1267 // {
1268 // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
1269 // ecartWeights=NULL;
1270 // }
1271 // }
1272  if (TEST_OPT_PROT) messageStat(hilbcount,strat);
1273  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
1274 
1275 
1276 #ifdef PDEBUG
1277 /* for counting number of pairs [enterL] in Plural */
1278 /* extern int zaehler; */
1279 /* Print("Total pairs considered:%d\n",zaehler); zaehler=0; */
1280 #endif /*PDEBUG*/
1281 
1282 #if MYTEST
1283  PrintS("</gnc_gr_bba>\n");
1284 #endif
1285 
1286  if( currRing != save ) rChangeCurrRing(save);
1287 
1288  return (strat->Shdl);
1289 }
#define TRUE
Definition: auxiliary.h:98
int k
Definition: cfEzgcd.cc:92
int syzComp
Definition: kutil.h:347
ring tailRing
Definition: kutil.h:336
int Ll
Definition: kutil.h:344
char honey
Definition: kutil.h:371
polyset S
Definition: kutil.h:297
poly tail
Definition: kutil.h:327
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:275
ideal Shdl
Definition: kutil.h:294
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:277
char interpt
Definition: kutil.h:365
LObject P
Definition: kutil.h:293
LSet L
Definition: kutil.h:318
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition: kutil.h:272
int(* red)(LObject *L, kStrategy strat)
Definition: kutil.h:269
int sl
Definition: kutil.h:341
unsigned long * sevS
Definition: kutil.h:313
char homog
Definition: kutil.h:366
int j
Definition: facHensel.cc:105
void nc_gr_initBba(ideal F, kStrategy strat)
nc_gr_initBba is needed for sca_gr_bba and gr_bba.
Definition: gr_kstd2.cc:952
#define idPrint(id)
Definition: ideals.h:46
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1087
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1107
int Kstd1_deg
Definition: kstd1.h:47
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7745
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:9894
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4775
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9721
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5981
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:9970
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4951
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5395
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10203
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1176
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9570
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10415
void messageSets(kStrategy strat)
Definition: kutil.cc:7816
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7786
static void kDeleteLcm(LObject *P)
Definition: kutil.h:844
static poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
Definition: nc.h:241
#define assume(x)
Definition: mod2.h:390
#define pNext(p)
Definition: monomials.h:37
#define NULL
Definition: omList.c:10
#define TEST_OPT_INTSTRATEGY
Definition: options.h:109
#define TEST_OPT_REDSB
Definition: options.h:103
#define TEST_OPT_DEGBOUND
Definition: options.h:112
#define TEST_OPT_SB_1
Definition: options.h:117
#define TEST_OPT_PROT
Definition: options.h:102
#define TEST_OPT_DEBUG
Definition: options.h:107
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2782
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:858
#define p_Test(p, r)
Definition: p_polys.h:164
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:235
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void rChangeCurrRing(ring r)
Definition: polys.cc:15
void wrp(poly p)
Definition: polys.h:304
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition: polys.h:70
void pWrite(poly p)
Definition: polys.h:302
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:357
#define pOne()
Definition: polys.h:309
poly nc_rat_CreateSpoly(poly pp1, poly pp2, int ishift, const ring r)
Definition: ratgring.cc:340
BOOLEAN p_LmIsConstantRat(const poly p, const ring r)
Definition: ratgring.cc:642
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:227
void rDebugPrint(const ring r)
Definition: ring.cc:4016
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:419
#define Q
Definition: sirandom.c:25
#define loop
Definition: structs.h:78

◆ k_gnc_gr_mora()

ideal k_gnc_gr_mora ( const ideal  F,
const ideal  Q,
const intvec ,
const intvec ,
kStrategy  strat,
const ring  _currRing 
)

Definition at line 1291 of file gr_kstd2.cc.

1292 {
1293 #ifndef SING_NDEBUG
1294  // Not yet!
1295  WarnS("Sorry, non-commutative mora is not yet implemented!");
1296 #endif
1297 
1298  return gnc_gr_bba(F, Q, NULL, NULL, strat, _currRing);
1299 }
#define WarnS
Definition: emacs.cc:78
BBA_Proc gnc_gr_bba
Definition: old.gring.cc:67

◆ nc_gr_initBba()

void nc_gr_initBba ( ideal  F,
kStrategy  strat 
)

nc_gr_initBba is needed for sca_gr_bba and gr_bba.

Definition at line 952 of file gr_kstd2.cc.

956 {
958 
959  // int i;
960 // idhdl h;
961  /* setting global variables ------------------- */
962  strat->enterS = enterSBba;
963 
964 /*
965  if ((BTEST1(20)) && (!strat->honey))
966  strat->red = nc_redBest;
967  else if (strat->honey)
968  strat->red = nc_redHoney;
969  else if (currRing->pLexOrder && !strat->homog)
970  strat->red = nc_redLazy;
971  else if (TEST_OPT_INTSTRATEGY && strat->homog)
972  strat->red = nc_redHomog0;
973  else
974  strat->red = nc_redHomog;
975 */
976 
977 // if (rIsPluralRing(currRing))
978  strat->red = redGrFirst;
979 #ifdef HAVE_RATGRING
980  if (rIsRatGRing(currRing))
981  {
982  int ii=IDELEMS(F)-1;
983  int jj;
984  BOOLEAN is_rat_id=FALSE;
985  for(;ii>=0;ii--)
986  {
987  for(jj=currRing->real_var_start;jj<=currRing->real_var_end;jj++)
988  {
989  if(pGetExp(F->m[ii],jj)>0) { is_rat_id=TRUE; break; }
990  }
991  if (is_rat_id) break;
992  }
993  if (is_rat_id) strat->red=redGrRatGB;
994  }
995 #endif
996 
997  if (currRing->pLexOrder && strat->honey)
998  strat->initEcart = initEcartNormal;
999  else
1000  strat->initEcart = initEcartBBA;
1001  if (strat->honey)
1003  else
1005 // if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1006 // {
1007 // //interred machen Aenderung
1008 // pFDegOld=currRing->pFDeg;
1009 // pLDegOld=currRing->pLDeg;
1010 // // h=ggetid("ecart");
1011 // // if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD))
1012 // // {
1013 // // ecartWeights=iv2array(IDINTVEC(h));
1014 // // }
1015 // // else
1016 // {
1017 // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
1018 // /*uses automatic computation of the ecartWeights to set them*/
1019 // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1020 // }
1021 // currRing->pFDeg=totaldegreeWecart;
1022 // currRing->pLDeg=maxdegreeWecart;
1023 // for(i=1; i<=(currRing->N); i++)
1024 // Print(" %d",ecartWeights[i]);
1025 // PrintLn();
1026 // mflush();
1027 // }
1028 }
int BOOLEAN
Definition: auxiliary.h:85
#define FALSE
Definition: auxiliary.h:94
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition: kutil.h:278
void(* initEcart)(TObject *L)
Definition: kutil.h:271
int redGrRatGB(LObject *h, kStrategy strat)
Definition: gr_kstd2.cc:225
int redGrFirst(LObject *h, kStrategy strat)
Definition: gr_kstd2.cc:53
void initEcartPairMora(LObject *Lp, poly, poly, int ecartF, int ecartG)
Definition: kutil.cc:1279
void initEcartNormal(TObject *h)
Definition: kutil.cc:1257
void initEcartBBA(TObject *h)
Definition: kutil.cc:1265
void initEcartPairBba(LObject *Lp, poly, poly, int, int)
Definition: kutil.cc:1272
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition: kutil.cc:9050
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:398
#define IDELEMS(i)
Definition: simpleideals.h:24

◆ ratGB_divide_out()

void ratGB_divide_out ( poly  p)

Definition at line 172 of file gr_kstd2.cc.

173 {
174  /* extracts monomial content from localized expression */
175  /* searches for an m (monomial in var 1.. real_var_start-1)
176  * such that m divides p and divides p by this m if it exist*/
177  if (p==NULL) return;
178  poly root=p;
180  poly f=pHead(p);
181  int i;
182  for (i=currRing->real_var_start;i<=currRing->real_var_end;i++)
183  {
184  pSetExp(f,i,0);
185  }
186  loop
187  {
188  pIter(p);
189  if (p==NULL) { pSetm(f); break;}
190  for (i=1;i<=rVar(currRing);i++)
191  {
193  }
194  }
195  if (!pIsConstant(f))
196  {
197 #ifdef KDEBUG
198  if (TEST_OPT_DEBUG)
199  {
200  PrintS("divide out:");p_wrp(f,currRing);
201  PrintS(" from ");pWrite(root);
202  }
203 #endif
204  p=root;
205  loop
206  {
207  if (p==NULL) break;
208  for (i=1;i<=rVar(currRing);i++)
209  {
210  pSetExp(p,i,pGetExp(p,i)-pGetExp(f,i));
211  }
212  pSetm(p);
213  pIter(p);
214  }
215  }
216  pDelete(&f);
217 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
int i
Definition: cfEzgcd.cc:125
int p
Definition: cfModGcd.cc:4019
FILE * f
Definition: checklibs.c:9
#define pIter(p)
Definition: monomials.h:38
#define pDelete(p_ptr)
Definition: polys.h:181
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define pSetm(p)
Definition: polys.h:265
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:233
#define pSetExp(p, i, v)
Definition: polys.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582

◆ redGrFirst()

int redGrFirst ( LObject h,
kStrategy  strat 
)

Definition at line 53 of file gr_kstd2.cc.

54 {
55  int at,reddeg,d,i;
56  int pass = 0;
57  int j = 0;
58 
59  d = currRing->pFDeg((*h).p,currRing)+(*h).ecart;
60  reddeg = strat->LazyDegree+d;
61  loop
62  {
63  if (j > strat->sl)
64  {
65 #ifdef KDEBUG
66  if (TEST_OPT_DEBUG) PrintLn();
67 #endif
68  return 0;
69  }
70 #ifdef KDEBUG
71  if (TEST_OPT_DEBUG) Print("%d",j);
72 #endif
73  if (pDivisibleBy(strat->S[j],(*h).p))
74  {
75 #ifdef KDEBUG
76  if (TEST_OPT_DEBUG) PrintS("+\n");
77 #endif
78  /*
79  * the polynomial to reduce with is;
80  * T[j].p
81  */
83  pNorm(strat->S[j]);
84 #ifdef KDEBUG
85  if (TEST_OPT_DEBUG)
86  {
87  wrp(h->p);
88  PrintS(" with ");
89  wrp(strat->S[j]);
90  }
91 #endif
92  (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p, currRing);
93  //spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether);
94 
95 #ifdef KDEBUG
96  if (TEST_OPT_DEBUG)
97  {
98  PrintS(" to ");
99  wrp(h->p);
100  }
101 #endif
102  if ((*h).p == NULL)
103  {
104  kDeleteLcm(h);
105  return 0;
106  }
108  {
109  h->pCleardenom();// also removes Content
110  }
111  /*computes the ecart*/
112  d = currRing->pLDeg((*h).p,&((*h).length),currRing);
113  (*h).FDeg=currRing->pFDeg((*h).p,currRing);
114  (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/
115  if ((strat->syzComp!=0) && !strat->honey)
116  {
117  if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
118  {
119 #ifdef KDEBUG
120  if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
121 #endif
122  return 0;
123  }
124  }
125  /*- try to reduce the s-polynomial -*/
126  pass++;
127  /*
128  *test whether the polynomial should go to the lazyset L
129  *-if the degree jumps
130  *-if the number of pre-defined reductions jumps
131  */
132  if ((strat->Ll >= 0)
133  && ((d >= reddeg) || (pass > strat->LazyPass))
134  && !strat->homog)
135  {
136  at = strat->posInL(strat->L,strat->Ll,h,strat);
137  if (at <= strat->Ll)
138  {
139  i=strat->sl+1;
140  do
141  {
142  i--;
143  if (i<0) return 0;
144  } while (!pDivisibleBy(strat->S[i],(*h).p));
145  enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
146 #ifdef KDEBUG
147  if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
148 #endif
149  (*h).p = NULL;
150  return 0;
151  }
152  }
153  if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
154  {
155  reddeg = d+1;
156  Print(".%d",d);mflush();
157  }
158  j = 0;
159 #ifdef KDEBUG
160  if TEST_OPT_DEBUG PrintLn();
161 #endif
162  }
163  else
164  {
165 #ifdef KDEBUG
166  if (TEST_OPT_DEBUG) PrintS("-");
167 #endif
168  j++;
169  }
170  }
171 }
int Lmax
Definition: kutil.h:344
int LazyPass
Definition: kutil.h:346
int LazyDegree
Definition: kutil.h:346
#define Print
Definition: emacs.cc:80
static Poly * h
Definition: janet.cc:972
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition: kutil.cc:1233
static poly nc_ReduceSpoly(const poly p1, poly p2, const ring r)
Definition: nc.h:254
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition: polys.h:138
#define pMinComp(p)
Definition: polys.h:294
#define mflush()
Definition: reporter.h:57

◆ redGrRatGB()

int redGrRatGB ( LObject h,
kStrategy  strat 
)

Definition at line 225 of file gr_kstd2.cc.

226 {
227  int at,reddeg,d,i;
228  int pass = 0;
229  int j = 0;
230  int c_j=-1, c_e=-2;
231  poly c_p=NULL;
232  assume(strat->tailRing==currRing);
233 
234  ratGB_divide_out((*h).p);
235  d = currRing->pFDeg((*h).p,currRing)+(*h).ecart;
236  reddeg = strat->LazyDegree+d;
238  {
239  h->pCleardenom();// also does a pContentRat
240  }
241  loop
242  {
243  if (j > strat->sl)
244  {
245  if (c_j>=0)
246  {
247  /*
248  * the polynomial to reduce with is;
249  * S[c_j]
250  */
252  pNorm(strat->S[c_j]);
253 #ifdef KDEBUG
254  if (TEST_OPT_DEBUG)
255  if (TEST_OPT_DEBUG)
256  {
257  wrp(h->p);
258  Print(" with S[%d]= ",c_j);
259  wrp(strat->S[c_j]);
260  }
261 #endif
262  //poly hh = nc_CreateSpoly(strat->S[c_j],(*h).p, currRing);
263  // Print("vor nc_rat_ReduceSpolyNew (ce:%d) ",c_e);wrp(h->p);PrintLn();
264  //if(c_e==-1)
265  // c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing);
266  //else
267  // c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],pCopy((*h).p), currRing->real_var_start-1,currRing);
268  // Print("nach nc_rat_ReduceSpolyNew ");wrp(c_p);PrintLn();
269  // pDelete(&((*h).p));
270 
271  c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],(*h).p, currRing->real_var_start-1,currRing);
272  (*h).p=c_p;
274  {
275  h->pCleardenom();// also removes Content
276  }
277 
278 #ifdef KDEBUG
279  if (TEST_OPT_DEBUG)
280  {
281  PrintS(" to ");
282  wrp(h->p);
283  PrintLn();
284  }
285 #endif
286  if ((*h).p == NULL)
287  {
288  kDeleteLcm(h);
289  return 0;
290  }
291  ratGB_divide_out((*h).p);
292  d = currRing->pLDeg((*h).p,&((*h).length),currRing);
293  (*h).FDeg=currRing->pFDeg((*h).p,currRing);
294  (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/
295  /*- try to reduce the s-polynomial again -*/
296  pass++;
297  j=0;
298  c_j=-1; c_e=-2; c_p=NULL;
299  }
300  else
301  { // nothing found
302  return 0;
303  }
304  }
305  // first try usal division
306  if (p_LmDivisibleBy(strat->S[j],(*h).p,currRing))
307  {
308 #ifdef KDEBUG
309  if(TEST_OPT_DEBUG)
310  {
311  p_wrp(h->p,currRing); Print(" divisible by S[%d]=",j);
312  p_wrp(strat->S[j],currRing); PrintS(" e=-1\n");
313  }
314 #endif
315  if ((c_j<0)||(c_e>=0))
316  {
317  c_e=-1; c_j=j;
318  }
319  }
320  else
321  if (p_LmDivisibleByPart(strat->S[j],(*h).p,currRing,
322  currRing->real_var_start,currRing->real_var_end))
323  {
324  int a_e=(p_Totaldegree(strat->S[j],currRing)-currRing->pFDeg(strat->S[j],currRing));
325 #ifdef KDEBUG
326  if(TEST_OPT_DEBUG)
327  {
328  p_wrp(h->p,currRing); Print(" divisibly by S[%d]=",j);
329  p_wrp(strat->S[j],currRing); Print(" e=%d\n",a_e);
330  }
331 #endif
332  if ((c_j<0)||(c_e>a_e))
333  {
334  c_e=a_e; c_j=j;
335  //c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing);
336  }
337  /*computes the ecart*/
338  if ((strat->syzComp!=0) && !strat->honey)
339  {
340  if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
341  {
342 #ifdef KDEBUG
343  if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
344 #endif
345  return 0;
346  }
347  }
348  }
349  else
350  {
351 #ifdef KDEBUG
352  if(TEST_OPT_DEBUG)
353  {
354  p_wrp(h->p,currRing); Print(" not divisibly by S[%d]=",j);
355  p_wrp(strat->S[j],currRing); PrintLn();
356  }
357 #endif
358  }
359  j++;
360  }
361 }
void ratGB_divide_out(poly p)
Definition: gr_kstd2.cc:172
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1821
static BOOLEAN p_LmDivisibleByPart(poly a, poly b, const ring r, const int start, const int end)
Definition: p_polys.h:1786
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1444
poly nc_rat_ReduceSpolyNew(const poly p1, poly p2, int ishift, const ring r)
Definition: ratgring.cc:465