My Project
Loading...
Searching...
No Matches
Macros | Functions
gr_kstd2.cc File Reference
#include "kernel/mod2.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 1028 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 1030 of file gr_kstd2.cc.

1031{
1032 const ring save = currRing; if( currRing != _currRing ) rChangeCurrRing(_currRing);
1033
1034#if MYTEST
1035 PrintS("<gnc_gr_bba>\n");
1036#endif
1037
1038#ifdef HAVE_PLURAL
1039#if MYTEST
1040 PrintS("currRing: \n");
1042#ifdef RDEBUG
1044#endif
1045
1046 PrintS("F: \n");
1047 idPrint(F);
1048 PrintS("Q: \n");
1049 idPrint(Q);
1050#endif
1051#endif
1052
1053 assume(currRing->OrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?)// alternate algebra?
1054
1055 // intvec *w=NULL;
1056 // intvec *hilb=NULL;
1057 int olddeg,reduc;
1058 int red_result=1;
1059 int /*hilbeledeg=1,*/hilbcount=0/*,minimcnt=0*/;
1060
1061 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
1062 // initHilbCrit(F,Q,&hilb,strat);
1063 /* in plural we don't need Hilb yet */
1064 nc_gr_initBba(F,strat);
1065 initBuchMoraPos(strat);
1066 if (rIsRatGRing(currRing))
1067 {
1068 strat->posInL=posInL0; // by pCmp of lcm
1069 }
1070 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
1071 /*Shdl=*/initBuchMora(F, Q,strat);
1072 strat->posInT=posInT110;
1073 reduc = olddeg = 0;
1074
1075 /* compute------------------------------------------------------- */
1076 while (strat->Ll >= 0)
1077 {
1078 if (TEST_OPT_DEBUG) messageSets(strat);
1079
1080 if (strat->Ll== 0) strat->interpt=TRUE;
1082 && ((strat->honey
1083 && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
1084 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
1085 {
1086 /*
1087 *stops computation if
1088 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
1089 *a predefined number Kstd1_deg
1090 */
1091 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1092 break;
1093 }
1094 /* picks the last element from the lazyset L */
1095 strat->P = strat->L[strat->Ll];
1096 strat->Ll--;
1097 //kTest(strat);
1098
1099 if (strat->P.p != NULL)
1100 if (pNext(strat->P.p) == strat->tail)
1101 {
1102 /* deletes the short spoly and computes */
1103 pLmFree(strat->P.p);
1104 /* the real one */
1105// if (ncRingType(currRing)==nc_lie) /* prod crit */
1106// if(pHasNotCF(strat->P.p1,strat->P.p2))
1107// {
1108// strat->cp++;
1109// /* prod.crit itself in nc_CreateSpoly */
1110// }
1111
1112
1113 if( ! rIsRatGRing(currRing) )
1114 {
1115 strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,currRing);
1116 }
1117#ifdef HAVE_RATGRING
1118 else
1119 {
1120 /* rational case */
1121 strat->P.p = nc_rat_CreateSpoly(strat->P.p1,strat->P.p2,currRing->real_var_start-1,currRing);
1122 }
1123#endif
1124
1125
1126#ifdef PDEBUG
1127 p_Test(strat->P.p, currRing);
1128#endif
1129
1130#if MYTEST
1131 if (TEST_OPT_DEBUG)
1132 {
1133 PrintS("p1: "); pWrite(strat->P.p1);
1134 PrintS("p2: "); pWrite(strat->P.p2);
1135 PrintS("SPoly: "); pWrite(strat->P.p);
1136 }
1137#endif
1138 }
1139
1140
1141 if (strat->P.p != NULL)
1142 {
1143 if (TEST_OPT_PROT)
1144 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
1145 &olddeg,&reduc,strat, red_result);
1146
1147#if MYTEST
1148 if (TEST_OPT_DEBUG)
1149 {
1150 PrintS("p1: "); pWrite(strat->P.p1);
1151 PrintS("p2: "); pWrite(strat->P.p2);
1152 PrintS("SPoly before: "); pWrite(strat->P.p);
1153 }
1154#endif
1155
1156 /* reduction of the element chosen from L */
1157 strat->red(&strat->P,strat);
1158
1159#if MYTEST
1160 if (TEST_OPT_DEBUG)
1161 {
1162 PrintS("red SPoly: "); pWrite(strat->P.p);
1163 }
1164#endif
1165 }
1166 if (strat->P.p != NULL)
1167 {
1168 if (TEST_OPT_PROT)
1169 {
1170 PrintS("s\n");
1171 }
1172 /* enter P.p into s and L */
1173 {
1174/* quick unit detection in the rational case */
1175#ifdef HAVE_RATGRING
1176 if( rIsRatGRing(currRing) )
1177 {
1178 if ( p_LmIsConstantRat(strat->P.p, currRing) )
1179 {
1180#ifdef PDEBUG
1181 PrintS("unit element detected:");
1182 p_wrp(strat->P.p,currRing);
1183#endif
1184 p_Delete(&strat->P.p,currRing, strat->tailRing);
1185 strat->P.p = pOne();
1186 }
1187 }
1188#endif
1189 strat->P.sev=0;
1190 int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart);
1191 {
1193 {
1194 if ((strat->syzComp==0)||(!strat->homog))
1195 {
1196 #ifdef HAVE_RATGRING
1197 if(!rIsRatGRing(currRing))
1198 #endif
1199 strat->P.p = redtailBba(strat->P.p,pos-1,strat);
1200 }
1201
1202 strat->P.p=p_Cleardenom(strat->P.p, currRing);
1203 }
1204 else
1205 {
1206 pNorm(strat->P.p);
1207 if ((strat->syzComp==0)||(!strat->homog))
1208 {
1209 strat->P.p = redtailBba(strat->P.p,pos-1,strat);
1210 }
1211 }
1212 if (TEST_OPT_DEBUG)
1213 {
1214 PrintS("new s:"); wrp(strat->P.p);
1215 PrintLn();
1216#if MYTEST
1217 PrintS("s: "); pWrite(strat->P.p);
1218#endif
1219
1220 }
1221 // kTest(strat);
1222 //
1223 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
1224
1225 if (strat->sl==-1) pos=0;
1226 else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
1227
1228 strat->enterS(strat->P,pos,strat,-1);
1229 }
1230// if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
1231 }
1232 kDeleteLcm(&strat->P);
1233 }
1234 //kTest(strat);
1235 }
1236 if (TEST_OPT_DEBUG) messageSets(strat);
1237
1238 /* complete reduction of the standard basis--------- */
1239 if (TEST_OPT_SB_1)
1240 {
1241 int k=1;
1242 int j;
1243 while(k<=strat->sl)
1244 {
1245 j=0;
1246 loop
1247 {
1248 if (j>=k) break;
1249 clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
1250 j++;
1251 }
1252 k++;
1253 }
1254 }
1255
1256 if (TEST_OPT_REDSB)
1257 completeReduce(strat);
1258 /* release temp data-------------------------------- */
1259 exitBuchMora(strat);
1260// if (TEST_OPT_WEIGHTM)
1261// {
1262// currRing->pFDeg=pFDegOld;
1263// currRing->pLDeg=pLDegOld;
1264// if (ecartWeights)
1265// {
1266// omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
1267// ecartWeights=NULL;
1268// }
1269// }
1270 if (TEST_OPT_PROT) messageStat(hilbcount,strat);
1271 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
1272
1273
1274#if MYTEST
1275 PrintS("</gnc_gr_bba>\n");
1276#endif
1277
1278 if( currRing != save ) rChangeCurrRing(save);
1279
1280 return (strat->Shdl);
1281}
#define TRUE
Definition: auxiliary.h:100
int k
Definition: cfEzgcd.cc:99
ring tailRing
Definition: kutil.h:343
int Ll
Definition: kutil.h:351
char honey
Definition: kutil.h:377
unsigned syzComp
Definition: kutil.h:354
polyset S
Definition: kutil.h:306
poly tail
Definition: kutil.h:334
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:284
ideal Shdl
Definition: kutil.h:303
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:286
char interpt
Definition: kutil.h:371
LObject P
Definition: kutil.h:302
LSet L
Definition: kutil.h:327
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition: kutil.h:281
int(* red)(LObject *L, kStrategy strat)
Definition: kutil.h:278
int sl
Definition: kutil.h:348
unsigned long * sevS
Definition: kutil.h:322
char homog
Definition: kutil.h:372
int j
Definition: facHensel.cc:110
void nc_gr_initBba(ideal F, kStrategy strat)
nc_gr_initBba is needed for sca_gr_bba and gr_bba.
Definition: gr_kstd2.cc:950
#define idPrint(id)
Definition: ideals.h:46
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1214
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1239
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7512
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:9800
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4509
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9627
int posInL0(const LSet set, const int length, LObject *p, const kStrategy)
Definition: kutil.cc:5643
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:9885
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4685
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5053
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10128
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1215
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9476
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition: kutil.cc:10340
void messageSets(kStrategy strat)
Definition: kutil.cc:7585
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7553
static void kDeleteLcm(LObject *P)
Definition: kutil.h:880
static poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
Definition: nc.h:241
#define assume(x)
Definition: mod2.h:389
#define pNext(p)
Definition: monomials.h:36
#define NULL
Definition: omList.c:12
#define TEST_OPT_INTSTRATEGY
Definition: options.h:111
#define TEST_OPT_REDSB
Definition: options.h:105
#define TEST_OPT_DEGBOUND
Definition: options.h:114
#define TEST_OPT_SB_1
Definition: options.h:120
#define TEST_OPT_PROT
Definition: options.h:104
#define TEST_OPT_DEBUG
Definition: options.h:109
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2845
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
#define p_Test(p, r)
Definition: p_polys.h:159
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void pNorm(poly p)
Definition: polys.h:362
void wrp(poly p)
Definition: polys.h:310
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:308
#define pOne()
Definition: polys.h:315
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:226
void rDebugPrint(const ring r)
Definition: ring.cc:4122
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:427
#define Q
Definition: sirandom.c:26
#define loop
Definition: structs.h:75

◆ 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 1283 of file gr_kstd2.cc.

1284{
1285 if ((ncRingType(_currRing)==nc_skew)
1286 || id_HomIdeal(F,Q,_currRing))
1287 return gnc_gr_bba(F, Q, NULL, NULL, strat, _currRing);
1288 else
1289 {
1290 WerrorS("not implemented: std for inhomogeneous ideasl in local orderings");
1291 return NULL;
1292 }
1293}
void WerrorS(const char *s)
Definition: feFopen.cc:24
EXTERN_VAR BBA_Proc gnc_gr_bba
Definition: gb_hack.h:10
@ nc_skew
Definition: nc.h:16
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)

◆ 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 950 of file gr_kstd2.cc.

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

◆ ratGB_divide_out()

void ratGB_divide_out ( poly  p)

Definition at line 170 of file gr_kstd2.cc.

171{
172 /* extracts monomial content from localized expression */
173 /* searches for an m (monomial in var 1.. real_var_start-1)
174 * such that m divides p and divides p by this m if it exist*/
175 if (p==NULL) return;
176 poly root=p;
178 poly f=pHead(p);
179 int i;
180 for (i=currRing->real_var_start;i<=currRing->real_var_end;i++)
181 {
182 pSetExp(f,i,0);
183 }
184 loop
185 {
186 pIter(p);
187 if (p==NULL) { pSetm(f); break;}
188 for (i=1;i<=rVar(currRing);i++)
189 {
191 }
192 }
193 if (!pIsConstant(f))
194 {
195#ifdef KDEBUG
196 if (TEST_OPT_DEBUG)
197 {
198 PrintS("divide out:");p_wrp(f,currRing);
199 PrintS(" from ");pWrite(root);
200 }
201#endif
202 p=root;
203 loop
204 {
205 if (p==NULL) break;
206 for (i=1;i<=rVar(currRing);i++)
207 {
209 }
210 pSetm(p);
211 pIter(p);
212 }
213 }
214 pDelete(&f);
215}
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
FILE * f
Definition: checklibs.c:9
#define pIter(p)
Definition: monomials.h:37
#define pDelete(p_ptr)
Definition: polys.h:186
#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:271
#define pIsConstant(p)
like above, except that Comp must be 0
Definition: polys.h:238
#define pSetExp(p, i, v)
Definition: polys.h:42
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592

◆ redGrFirst()

int redGrFirst ( LObject h,
kStrategy  strat 
)

Definition at line 51 of file gr_kstd2.cc.

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

◆ redGrRatGB()

int redGrRatGB ( LObject h,
kStrategy  strat 
)

Definition at line 223 of file gr_kstd2.cc.

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