Changeset cfce45f in git
- Timestamp:
- Aug 31, 2018, 1:32:41 PM (5 years ago)
- Branches:
- (u'spielwiese', 'a719bcf0b8dbc648b128303a49777a094b57592c')
- Children:
- de5dbc0c9dbc380f0c1708cae5c481c59c9fdee5
- Parents:
- 72436190c57e0fc29bf8613364fedc842ab8f9506cc0f0e69248967085f5a4a1e494eacbc3065e2d
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/freegb.lib
r6cc0f0 rcfce45f 1 /////////////////////////////////////////////////////////////////////////////2 1 ///////////////////////////////////////////////////////////////////////////// 3 2 version="version freegb.lib 4.1.1.0 Dec_2017 "; // $Id$ … … 92 91 ERROR("uptodeg and lV do not agree on the basering!"); 93 92 } 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 99 101 attrib(@R, "uptodeg", uptodeg); 100 102 attrib(@R, "isLetterplaceRing", lV); … … 500 502 // assumes of the ring have been checked 501 503 // run the computation - it will test assumes on the ideal 502 int uptodeg = attrib(save,"uptodeg");503 int lV = attrib(save,"isLetterplaceRing");504 504 dbprint(ppl,"start computing GB"); 505 def J = system("freegb",I ,uptodeg,lV);505 def J = system("freegb",I); 506 506 dbprint(ppl,"finished computing GB"); 507 507 dbprint(ppl-1,"the result is:"); … … 2525 2525 ERROR("Incomplete Letterplace structure on the basering!"); 2526 2526 } 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)); 2530 2528 } 2531 2529 example -
Singular/extra.cc
r6cc0f0 rcfce45f 1164 1164 if (strcmp(sys_cmd, "stest") == 0) 1165 1165 { 1166 const short t[]={ 4,POLY_CMD,INT_CMD,INT_CMD,INT_CMD};1166 const short t[]={2,POLY_CMD,INT_CMD}; 1167 1167 if (iiCheckTypes(h,t,1)) 1168 1168 { … … 1170 1170 h=h->next; 1171 1171 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()));1176 1172 if (sh<0) 1177 1173 { … … 1179 1175 return TRUE; 1180 1176 } 1181 int L = pLastVblock(p ,lVblock);1182 if (L+sh > uptodeg)1177 int L = pLastVblock(p); 1178 if (L+sh > currRing->N/currRing->isLPring) 1183 1179 { 1184 1180 WerrorS("pLPshift: too big shift requested\n"); 1185 1181 return TRUE; 1186 1182 } 1187 res->data = p_LPshift(p,sh, uptodeg,lVblock,currRing);1183 res->data = p_LPshift(p,sh,currRing); 1188 1184 res->rtyp = POLY_CMD; 1189 1185 return FALSE; … … 1197 1193 if (strcmp(sys_cmd, "btest") == 0) 1198 1194 { 1199 const short t[]={ 2,POLY_CMD,INT_CMD};1195 const short t[]={1,POLY_CMD}; 1200 1196 if (iiCheckTypes(h,t,1)) 1201 1197 { 1202 1198 poly p=(poly)h->CopyD(); 1203 h=h->next;1204 int lV=(int)((long)(h->Data()));1205 1199 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); 1228 1201 return FALSE; 1229 1202 } … … 1504 1477 if (strcmp(sys_cmd, "freegb") == 0) 1505 1478 { 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}; 1508 1481 if (iiCheckTypes(h,tM,0) 1509 1482 || (iiCheckTypes(h,t,0))) … … 1511 1484 res->rtyp=h->Typ(); 1512 1485 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); 1518 1487 if (res->data == NULL) 1519 1488 { … … 1525 1494 else 1526 1495 { 1527 WerrorS("system(\"freegb\",`ideal/module` ,`int`,`int`) expected");1496 WerrorS("system(\"freegb\",`ideal/module`) expected"); 1528 1497 return TRUE; 1529 1498 } -
kernel/GBEngine/kInline.h
r6cc0f0 rcfce45f 31 31 #include "kernel/polys.h" 32 32 33 #include "kernel/GBEngine/shiftgb.h" 33 34 34 35 #define HAVE_TAIL_BIN -
kernel/GBEngine/kspoly.cc
r6cc0f0 rcfce45f 20 20 #include "kernel/polys.h" 21 21 #endif 22 #include "kernel/GBEngine/shiftgb.h" 22 23 23 24 #ifdef KDEBUG … … 123 124 } 124 125 126 poly lmRight; 127 if (tailRing->isLPring) { 128 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing); 129 } 130 125 131 // take care of coef buisness 126 132 if (! n_IsOne(pGetCoeff(p2), tailRing->cf)) … … 130 136 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 131 137 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 132 139 if ((ct == 0) || (ct == 2)) 133 140 PR->Tail_Mult_nn(an); … … 142 149 143 150 // 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 } 145 156 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 146 157 PR->LmDeleteAndIter(); 147 148 // the following is commented out: shrinking149 #ifdef HAVE_SHIFTBBA_NONEXISTENT150 if ( (currRing->isLPring) && (!strat->homog) )151 {152 // assume? h->p in currRing153 PR->GetP();154 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);155 PR->Clear(); // does the right things156 PR->p = qq;157 PR->t_p = NULL;158 PR->SetShortExpVector();159 }160 #endif161 158 162 159 return ret; … … 400 397 } 401 398 399 poly lmRight; 400 if (tailRing->isLPring) { 401 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing); 402 } 403 402 404 // take care of coef buisness 403 405 if (! n_IsOne(pGetCoeff(p2), tailRing)) … … 407 409 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 408 410 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 409 412 if ((ct == 0) || (ct == 2)) 410 413 PR->Tail_Mult_nn(an); … … 419 422 420 423 // 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 } 422 429 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 423 430 PR->LmDeleteAndIter(); 424 425 // the following is commented out: shrinking426 #ifdef HAVE_SHIFTBBA_NONEXISTENT427 if ( (currRing->isLPring) && (!strat->homog) )428 {429 // assume? h->p in currRing430 PR->GetP();431 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);432 PR->Clear(); // does the right things433 PR->p = qq;434 PR->t_p = NULL;435 PR->SetShortExpVector();436 }437 #endif438 431 439 432 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) … … 606 599 } 607 600 601 poly lmRight; 602 if (tailRing->isLPring) { 603 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing); 604 } 605 608 606 // take care of coef buisness 609 607 if (! n_IsOne(pGetCoeff(p2), tailRing->cf)) … … 613 611 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 614 612 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 615 614 if ((ct == 0) || (ct == 2)) 616 615 PR->Tail_Mult_nn(an); … … 625 624 626 625 // 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 } 628 631 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 629 632 PR->LmDeleteAndIter(); 630 631 // the following is commented out: shrinking632 #ifdef HAVE_SHIFTBBA_NONEXISTENT633 if ( (currRing->isLPring) && (!strat->homog) )634 {635 // assume? h->p in currRing636 PR->GetP();637 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);638 PR->Clear(); // does the right things639 PR->p = qq;640 PR->t_p = NULL;641 PR->SetShortExpVector();642 }643 #endif644 633 645 634 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) … … 844 833 } 845 834 } 835 836 poly lmRight; 837 if (tailRing->isLPring) { 838 k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing); 839 } 840 846 841 // take care of coef buisness 847 842 if(rField_is_Ring(currRing)) 848 843 { 849 844 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 850 846 if (coef != NULL) *coef = n_Init(1, tailRing->cf); 851 847 } … … 858 854 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 859 855 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 860 857 if (((ct == 0) || (ct == 2))) 861 858 PR->Tail_Mult_nn(an); … … 870 867 871 868 // 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 } 873 874 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 874 875 PR->LmDeleteAndIter(); 875 876 876 // the following is commented out: shrinking877 #ifdef HAVE_SHIFTBBA_NONEXISTENT878 if ( (currRing->isLPring) && (!strat->homog) )879 {880 // assume? h->p in currRing881 PR->GetP();882 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);883 PR->Clear(); // does the right things884 PR->p = qq;885 PR->t_p = NULL;886 PR->SetShortExpVector();887 }888 #endif889 877 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 890 878 if (TEST_OPT_DEBUG) … … 947 935 k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing); 948 936 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 949 952 pSetCoeff0(m1, lc2); 950 953 pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2) … … 978 981 } 979 982 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 } 981 989 #ifdef HAVE_RINGS 982 990 if (!(rField_is_Domain(currRing))) l2 = pLength(a2); … … 985 993 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing); 986 994 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 } 989 1002 990 1003 // Clean-up time 991 1004 Pair->LmDeleteAndIter(); 992 1005 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 } 993 1012 994 1013 if (co != 0) … … 1003 1022 } 1004 1023 } 1005 1006 // the following is commented out: shrinking1007 #ifdef HAVE_SHIFTBBA_NONEXISTENT1008 if (currRing->isLPring)1009 {1010 // assume? h->p in currRing1011 Pair->GetP();1012 poly qq = p_Shrink(Pair->p, currRing->isLPring, currRing);1013 Pair->Clear(); // does the right things1014 Pair->p = qq;1015 Pair->t_p = NULL;1016 Pair->SetShortExpVector();1017 }1018 #endif1019 1020 1024 } 1021 1025 … … 1059 1063 With.Delete(); 1060 1064 1061 // the following is commented out: shrinking1062 #ifdef HAVE_SHIFTBBA_NONEXISTENT1063 if (currRing->isLPring)1064 {1065 // assume? h->p in currRing1066 PR->GetP();1067 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);1068 PR->Clear(); // does the right things1069 PR->p = qq;1070 PR->t_p = NULL;1071 PR->SetShortExpVector();1072 }1073 #endif1074 1075 1065 return ret; 1076 1066 } … … 1114 1104 if (Lp == Save) 1115 1105 With.Delete(); 1116 1117 // the following is commented out: shrinking1118 #ifdef HAVE_SHIFTBBA_NONEXISTENT1119 if (currRing->isLPring)1120 {1121 // assume? h->p in currRing1122 PR->GetP();1123 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);1124 PR->Clear(); // does the right things1125 PR->p = qq;1126 PR->t_p = NULL;1127 PR->SetShortExpVector();1128 }1129 #endif1130 1106 1131 1107 return ret; -
kernel/GBEngine/kstd1.cc
r6cc0f0 rcfce45f 2565 2565 #ifdef HAVE_SHIFTBBA 2566 2566 ideal 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) 2568 2568 { 2569 2569 ideal r; … … 2597 2597 if (h==testHomog) 2598 2598 { 2599 if (delete_w)2600 {2601 temp_w=new intvec((strat->ak)+1);2602 w = &temp_w;2603 }2604 2599 if (strat->ak == 0) 2605 2600 { … … 2646 2641 /* global ordering */ 2647 2642 if (w!=NULL) 2648 r=bbaShift(F,Q,*w,hilb,strat ,uptodeg,lV);2643 r=bbaShift(F,Q,*w,hilb,strat); 2649 2644 else 2650 r=bbaShift(F,Q,NULL,hilb,strat ,uptodeg,lV);2645 r=bbaShift(F,Q,NULL,hilb,strat); 2651 2646 } 2652 2647 #ifdef KDEBUG -
kernel/GBEngine/kstd1.h
r6cc0f0 rcfce45f 40 40 41 41 ideal 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); 43 43 44 44 /* the following global data are defined in kutil.cc */ -
kernel/GBEngine/kstd2.cc
r6cc0f0 rcfce45f 4040 4040 4041 4041 4042 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat , int uptodeg, int lV)4042 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) 4043 4043 { 4044 4044 int red_result = 1; 4045 4045 int olddeg,reduc; 4046 4046 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); 4048 4050 4049 4051 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */ … … 4056 4058 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ 4057 4059 /*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 */ 4060 4061 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); 4061 4062 reduc = olddeg = 0; 4062 strat->lV=lV;4063 4063 4064 4064 #ifndef NO_BUCKETS … … 4066 4066 strat->use_buckets = 1; 4067 4067 #endif 4068 4069 4068 // redtailBBa against T for inhomogenous input 4070 4069 // if (!TEST_OPT_OLDSTD) … … 4079 4078 #endif 4080 4079 4080 4081 #ifdef KDEBUG 4082 //kDebugPrint(strat); 4083 #endif 4081 4084 /* compute------------------------------------------------------- */ 4082 4085 while (strat->Ll >= 0) … … 4136 4139 } 4137 4140 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 structure4145 /* in the nonhomog case we have to shrink the polynomial */4146 qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink4147 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 length4154 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 else4161 {4162 /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/4163 #ifdef KDEBUG4164 if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0\n");}4165 #endif4166 strat->P.p = NULL;4167 strat->P.t_p = NULL;4168 }4169 }4170 /* end shrinking poly in the nonhomog case */4171 4172 4141 if (strat->P.p == NULL && strat->P.t_p == NULL) 4173 4142 { … … 4182 4151 /* reduction of the element chosen from L */ 4183 4152 red_result = strat->red(&strat->P,strat); 4153 if (errorreported) break; 4184 4154 } 4185 4155 … … 4187 4157 if (red_result == 1) 4188 4158 { 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 4189 4166 /* statistic */ 4190 4167 if (TEST_OPT_PROT) PrintS("s"); 4191 4168 4192 // get the polynomial (canonicalize bucket, make sure P.p is set)4193 strat->P.GetP(strat->lmBin);4194 4195 4169 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); 4196 4170 4197 4171 // 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; 4198 4175 if (TEST_OPT_INTSTRATEGY) 4199 4176 { … … 4203 4180 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); 4204 4181 strat->P.pCleardenom(); 4182 if (strat->redTailChange) { 4183 strat->P.t_p=NULL; 4184 strat->initEcart(&(strat->P)); 4185 } 4205 4186 } 4206 4187 } … … 4208 4189 { 4209 4190 strat->P.pNorm(); 4210 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 4191 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) { 4211 4192 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 } 4216 4199 4217 4200 #ifdef KDEBUG … … 4240 4223 } 4241 4224 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 structure4247 /* 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 shrink4251 if (qq != NULL)4252 {4253 /* we're here if Shrink is nonzero */4254 strat->P.p = qq; // is not set by Delete4255 strat->P.t_p = NULL;4256 strat->P.GetP(strat->lmBin);4257 // update sev and length4258 strat->initEcart(&(strat->P));4259 strat->P.sev = pGetShortExpVector(strat->P.p);4260 }4261 else4262 {4263 /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/4264 #ifdef PDEBUG4265 if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}4266 #endif4267 strat->P.p = NULL;4268 strat->P.t_p = NULL;4269 goto red_shrink2zero;4270 }4271 }4272 else4273 {4274 qq = p_Shrink(strat->P.p, lV, currRing); // direct shrink4275 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 length4281 strat->initEcart(&(strat->P));4282 strat->P.sev = pGetShortExpVector(strat->P.p);4283 }4284 else4285 {4286 /* Shrink is zero, like y(1)*y(2) - y(1)*y(3)*/4287 #ifdef PDEBUG4288 if (TEST_OPT_DEBUG){PrintS("nonzero s shrinks to 0");PrintLn();}4289 #endif4290 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 4298 4225 4299 4226 // 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 } 4313 4235 4314 4236 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 4315 4237 // Print("[%d]",hilbeledeg); 4316 4238 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); 4325 4260 } 4326 4261 #ifdef KDEBUG … … 4332 4267 if (TEST_OPT_DEBUG) messageSets(strat); 4333 4268 #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 } 4334 4290 /* 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)4337 4291 if (TEST_OPT_REDSB) 4338 4292 { 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 4374 4294 if (strat->completeReduce_retry) 4375 4295 { … … 4384 4304 int i; 4385 4305 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 4386 4307 completeReduce(strat); 4387 4308 } … … 4404 4325 // } 4405 4326 // } 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 ------------------*/ 4407 4330 if (Q!=NULL) updateResult(strat->Shdl,Q,strat); 4331 4332 idTest(strat->Shdl); 4333 4408 4334 return (strat->Shdl); 4409 4335 } 4410 4336 4411 4337 4412 ideal freegb(ideal I , int uptodeg, int lVblock)4338 ideal freegb(ideal I) 4413 4339 { 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)); 4439 4349 return(RS); 4440 4350 } … … 4479 4389 #endif 4480 4390 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 }4487 4391 4488 4392 #ifdef KDEBUG -
kernel/GBEngine/kstdfac.cc
r6cc0f0 rcfce45f 229 229 s->noetherSet=o->noetherSet; 230 230 #ifdef HAVE_SHIFTBBA 231 s-> lV=o->lV;231 s->cv=o->cv; 232 232 #endif 233 233 #ifdef HAVE_PLURAL -
kernel/GBEngine/kutil.cc
r724361 rcfce45f 882 882 if (L->p!=NULL) 883 883 { 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 } 886 891 } 887 892 if (L->t_p!=NULL) 888 893 { 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 } 891 900 } 892 901 if ((L->p!=NULL)&&(L->t_p!=NULL)) assume(pGetCoeff(L->p)==pGetCoeff(L->t_p)); -
kernel/GBEngine/kutil.h
r6cc0f0 rcfce45f 95 95 /*BOOLEAN*/ char is_special; // true, it is a new special S-poly (e.g. for SCA) 96 96 #endif 97 98 // letterplace 99 int shift; 97 100 98 101 // initialization … … 362 365 #endif 363 366 #ifdef HAVE_SHIFTBBA 364 int lV;365 367 int cv; // in shift bases: counting V criterion 366 368 #endif … … 827 829 poly pCopyL2p(LObject h, kStrategy strat); 828 830 829 void enterTShift(LObject p, kStrategy strat, int atT , int uptodeg, int lV);831 void enterTShift(LObject p, kStrategy strat, int atT = -1); 830 832 831 833 void initBuchMoraShift (ideal F,ideal Q,kStrategy strat); 832 834 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); // ok836 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);835 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR); 836 837 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS); 838 839 void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR); 840 841 void updateSShift(kStrategy strat); 840 842 841 843 void initBbaShift(kStrategy strat); … … 845 847 int redFirstShift (LObject* h,kStrategy strat); // ok 846 848 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);849 ideal freegb(ideal I); 850 851 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); 850 852 // test syz strategy: // will be removed soon 851 853 extern int (*test_PosInT)(const TSet T,const int tl,LObject &h); -
kernel/GBEngine/shiftgb.cc
r6cc0f0 rcfce45f 35 35 #define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int)) 36 36 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) 37 poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r) 42 38 { 43 39 /* assume shift takes place, shifts the poly p by sh */ … … 55 51 56 52 poly q = NULL; 57 poly s = p_mLPshift(p_Head(p,r), sh, uptodeg, lV,r); // lm in currRing53 poly s = p_mLPshift(p_Head(p,r), sh, r); // lm in currRing 58 54 /* pNext(s) will be fixed below */ 59 55 poly pp = pNext(p); … … 61 57 while (pp != NULL) 62 58 { 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); 64 60 pIter(pp); 65 61 … … 71 67 } 72 68 73 poly p_LPshift(poly p, int sh, int uptodeg, int lV,const ring r)69 poly p_LPshift(poly p, int sh, const ring r) 74 70 { 75 71 /* assume shift takes place */ … … 77 73 78 74 /* assume sh and uptodeg agree TODO check */ 79 assume(sh>=0);80 75 81 76 if (sh == 0) return(p); /* the zero shift */ … … 88 83 pIter(pp); 89 84 pNext(h)=NULL; 90 h=p_mLPshift(h,sh, uptodeg,lV,r);85 h=p_mLPshift(h,sh,r); 91 86 q = p_Add_q(q, h,r); 92 87 } … … 94 89 } 95 90 96 poly p_mLPshift(poly p, int sh, int uptodeg, int lV,const ring r)91 poly p_mLPshift(poly p, int sh, const ring r) 97 92 { 98 93 /* p is a monomial from the ring r */ 99 94 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); 105 102 106 103 int *e=(int *)omAlloc0((r->N+1)*sizeof(int)); … … 117 114 { 118 115 assume(j + (sh*lV)<=r->N); 116 assume(j + (sh*lV)>=1); 119 117 s[j + (sh*lV)] = e[j]; /* actually 1 */ 120 118 } … … 130 128 } 131 129 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 */ 133 int p_LastVblock(poly p, const ring r) 134 { 160 135 poly q = p; 161 136 int ans = 0; 162 int ansnew = 0;163 137 while (q!=NULL) 164 138 { 165 ansnew = p_mLastVblock(q, lV, r);139 int ansnew = p_mLastVblock(q, r); 166 140 ans = si_max(ans,ansnew); 167 141 pIter(q); … … 170 144 } 171 145 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 */ 148 int p_mLastVblock(poly p, const ring r) 149 { 150 if (p == NULL || p_LmIsConstantComp(p,r)) 177 151 { 178 152 return(0); 179 153 } 154 155 int lV = r->isLPring; 180 156 int *e=(int *)omAlloc0((r->N+1)*sizeof(int)); 181 157 p_GetExpV(p,e,r); … … 189 165 } 190 166 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 */ 170 int 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); 199 178 while (q!=NULL) 200 179 { 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 } 203 184 pIter(q); 204 185 } … … 207 188 } 208 189 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 */ 192 int 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); 219 202 int j,b; 220 203 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 */ 230 208 return (b); 231 209 } 232 210 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 215 int isInV(poly p, const ring r) 216 { 217 int lV = r->isLPring; 239 218 /* investigate only the leading monomial of p in currRing */ 240 219 if ( pTotaldegree(p)==0 ) return(1); 241 if (lV <= 0) return(0);242 220 /* returns 1 iff p is in V */ 243 221 /* that is in each block up to a certain one there is only one nonzero exponent */ … … 287 265 } 288 266 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 */ 268 int poly_isInV(poly p, const ring r) 269 { 292 270 poly q = p; 293 271 while (q!=NULL) 294 272 { 295 if ( !isInV(q, lV) )273 if ( !isInV(q, r) ) 296 274 { 297 275 return(0); … … 302 280 } 303 281 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 */ 283 int ideal_isInV(ideal I, const ring r) 284 { 307 285 int i; 308 286 int s = IDELEMS(I)-1; 309 287 for(i = 0; i <= s; i++) 310 288 { 311 if ( !poly_isInV(I->m[i], lV) )289 if ( !poly_isInV(I->m[i], r) ) 312 290 { 313 291 return(0); … … 318 296 319 297 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 */ 299 int itoInsert(poly p, const ring r) 300 { 323 301 /* the below situation (commented out) might happen! */ 324 302 // if (r == currRing) … … 328 306 // } 329 307 /* compute the number of insertions */ 330 int i = p_mLastVblock(p, lV,currRing);308 int i = p_mLastVblock(p, currRing); 331 309 if (pNext(p) != NULL) 332 310 { 333 i = si_max(i, p_LastVblock(pNext(p), lV,r) );311 i = si_max(i, p_LastVblock(pNext(p), r) ); 334 312 } 335 313 // i = uptodeg - i +1; 336 i = uptodeg - i;314 int uptodeg = r->N/r->isLPring; 337 315 // 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 321 void 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 422 334 #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 preserved431 p_SetCoeff(s,n_Copy(p_GetCoeff(p,r),r->cf),r); // coeff is preserved432 #ifdef PDEBUG433 // Print("p_mShrink: from "); p_wrp(p,r); Print(" to "); p_wrp(s,r); PrintLn();434 #endif435 return(s);436 }437 438 /* shiftgb stuff */439 440 441 /*2442 *if the leading term of p443 *divides the leading term of some T[i] it will be canceled444 */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 deletion462 enlargeT: just reallocation */463 464 #endif -
kernel/GBEngine/shiftgb.h
r6cc0f0 rcfce45f 12 12 #include "polys/nc/nc.h" 13 13 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); 14 poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r); 16 15 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); 16 poly p_LPshift(poly p, int sh, const ring r); 17 poly p_mLPshift(poly p, int sh, const ring r); 22 18 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);19 int p_mLastVblock(poly p, const ring r); 20 int p_LastVblock(poly p, const ring r); 25 21 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) 28 24 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) 25 int p_FirstVblock(poly p, const ring r); 26 int p_mFirstVblock(poly p, const ring r); 33 27 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) 36 30 37 int isInV(poly p, int lV);38 int poly_isInV(poly p, int lV);39 int ideal_isInV(ideal I, int lV);31 int isInV(poly p, const ring r); 32 int poly_isInV(poly p, const ring r); 33 int ideal_isInV(ideal I, const ring r); 40 34 41 int itoInsert(poly p, int uptodeg, int lV,const ring r);35 int itoInsert(poly p, const ring r); 42 36 37 void k_SplitFrame(poly &m1, poly &m2, int at, const ring r); 43 38 #endif 44 39 #endif -
libpolys/coeffs/longrat.cc
r6cc0f0 rcfce45f 1638 1638 #endif 1639 1639 } 1640 1640 #ifdef LDEBUG 1641 1641 memset(*a,0,sizeof(**a)); 1642 1642 #endif 1643 1643 FREE_RNUMBER(*a); // omFreeBin((void *) *a, rnumber_bin); 1644 1644 } -
libpolys/polys/Makefile.am
r6cc0f0 rcfce45f 35 35 kbuckets.cc sbuckets.cc weight.cc weight0.c simpleideals.cc matpol.cc \ 36 36 sparsmat.cc \ 37 shiftop.cc \ 37 38 ${USE_P_PROCS_STATIC_CC} ${USE_P_PROCS_DYNAMIC_CC} mod_raw.cc \ 38 39 ext_fields/algext.cc ext_fields/transext.cc \ … … 47 48 kbuckets.h sbuckets.h simpleideals.h weight.h matpol.h \ 48 49 sparsmat.h clapsing.h clapconv.h coeffrings.h flintconv.h\ 50 shiftop.h \ 49 51 ext_fields/algext.h ext_fields/transext.h mod_raw.h 50 52 -
libpolys/polys/kbuckets.cc
r6cc0f0 rcfce45f 738 738 { 739 739 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); 741 741 pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf)); 742 742 l1=pLength(p1); … … 780 780 else 781 781 { 782 p1 = r->p_Procs->pp_ Mult_mm(p1, m, r);782 p1 = r->p_Procs->pp_mm_Mult(p1, m, r); 783 783 } 784 784 pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf)); -
libpolys/polys/templates/p_Procs_Set.h
r6cc0f0 rcfce45f 16 16 #include "reporter/reporter.h" 17 17 #include "misc/auxiliary.h" 18 #include "shiftop.h" 18 19 19 20 // extract p_Procs properties from a ring … … 165 166 } 166 167 #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 } 169 182 CheckProc(p_Copy); 170 183 CheckProc(p_Delete);
Note: See TracChangeset
for help on using the changeset viewer.