Changeset d681e8 in git
- Timestamp:
- May 19, 2007, 3:22:23 PM (16 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cdfcdb8287f66bc6070028082cbbc6eff10e609b')
- Children:
- aef8bb403e723cf3c64015379df7cbc448fbb3b3
- Parents:
- 1591a873ae939d12cc28f2fbb1408a9e8fdad9b8
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kInline.cc
r1591a87 rd681e8 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: kInline.cc,v 1. 5 2007-02-01 18:22:35 SingularExp $9 * Version: $Id: kInline.cc,v 1.6 2007-05-19 13:22:22 wienand Exp $ 10 10 *******************************************************************/ 11 11 #ifndef KINLINE_CC … … 958 958 } 959 959 960 #ifdef HAVE_RINGS 961 // get m1 = LCM(LM(p1), LM(p2))/LM(p1) 962 // m2 = LCM(LM(p1), LM(p2))/LM(p2) in tailRing 963 // lcm = LCM(LM(p1), LM(p2) in leadRing 964 KINLINE BOOLEAN k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, 965 poly &m1, poly &m2, poly &lcm, const ring tailRing) 966 { 967 p_LmCheckPolyRing(p1, leadRing); 968 p_LmCheckPolyRing(p2, leadRing); 969 970 int i; 971 Exponent_t x; 972 Exponent_t e1; 973 Exponent_t e2; 974 Exponent_t s; 975 m1 = p_Init(tailRing); 976 m2 = p_Init(tailRing); 977 lcm = p_Init(leadRing); 978 979 for (i = leadRing->N; i; i--) 980 { 981 e1 = p_GetExp(p1,i,leadRing); 982 e2 = p_GetExp(p2,i,leadRing); 983 x = e1 - e2; 984 s = e1 + e2; 985 if (x > 0) 986 { 987 p_SetExp(m2,i,x, tailRing); 988 p_SetExp(m1,i,0, tailRing); 989 } 990 else 991 { 992 p_SetExp(m1,i,-x, tailRing); 993 p_SetExp(m2,i,0, tailRing); 994 } 995 p_SetExp(lcm,i,s, leadRing); 996 } 997 998 p_Setm(m1, tailRing); 999 p_Setm(m2, tailRing); 1000 p_Setm(lcm, leadRing); 1001 return TRUE; 1002 1003 false_return: 1004 p_LmFree(m1, tailRing); 1005 p_LmFree(m2, tailRing); 1006 m1 = m2 = NULL; 1007 return FALSE; 1008 } 1009 #endif 1010 960 1011 /*************************************************************** 961 1012 * -
kernel/kutil.cc
r1591a87 rd681e8 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.5 3 2007-05-11 10:48:04wienand Exp $ */4 /* $Id: kutil.cc,v 1.54 2007-05-19 13:22:22 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 1031 1031 /*- computes the lcm(s[i],p) -*/ 1032 1032 Lp.lcm = pInit(); 1033 1033 pSetCoeff(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing)); 1034 // Lp.lcm == 0 1035 if (pGetCoeff(Lp.lcm) == NULL) 1036 { 1037 #ifdef KDEBUG 1038 if (TEST_OPT_DEBUG) 1039 { 1040 PrintS("--- Lp.lcm == 0\n"); 1041 PrintS("p:"); 1042 wrp(p); 1043 Print(" strat->S[%d]:", i); 1044 wrp(strat->S[i]); 1045 PrintLn(); 1046 } 1047 #endif 1048 strat->cp++; 1049 pLmFree(Lp.lcm); 1050 Lp.lcm=NULL; 1051 return; 1052 } 1053 // basic product criterion 1034 1054 pLcm(p,strat->S[i],Lp.lcm); 1035 1055 pSetm(Lp.lcm); 1036 pSetCoeff(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing));1037 1056 assume(!strat->sugarCrit); 1038 // basic product criterion 1039 if (pHasNotCF(p,strat->S[i]) && (long) pGetCoeff(p) % 2 == 1 && (long) pGetCoeff(strat->S[i]) % 2 == 1) 1040 { 1057 if (pHasNotCF(p,strat->S[i]) && nIsOne(nGcd(0, pGetCoeff(p), currRing)) && nIsOne(nGcd(0, pGetCoeff(strat->S[i]), currRing))) 1058 { 1059 #ifdef KDEBUG 1060 if (TEST_OPT_DEBUG) 1061 { 1062 PrintS("--- product criterion func enterOnePairRing type 1\n"); 1063 PrintS("p:"); 1064 wrp(p); 1065 Print(" strat->S[%d]:", i); 1066 wrp(strat->S[i]); 1067 PrintLn(); 1068 } 1069 #endif 1041 1070 strat->cp++; 1042 1071 pLmFree(Lp.lcm); … … 1060 1089 { 1061 1090 strat->c3++; 1091 #ifdef KDEBUG 1092 if (TEST_OPT_DEBUG) 1093 { 1094 PrintS("--- chain criterion type 1\n"); 1095 PrintS("strat->B[j]:"); 1096 wrp(strat->B[j].lcm); 1097 PrintS(" Lp.lcm:"); 1098 wrp(Lp.lcm); 1099 PrintLn(); 1100 } 1101 #endif 1062 1102 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) 1063 1103 { … … 1070 1110 if (compare == -1) 1071 1111 { 1112 #ifdef KDEBUG 1113 if (TEST_OPT_DEBUG) 1114 { 1115 PrintS("--- chain criterion type 2\n"); 1116 Print("strat->B[%d].lcm:",j); 1117 wrp(strat->B[j].lcm); 1118 PrintS(" Lp.lcm:"); 1119 wrp(Lp.lcm); 1120 PrintLn(); 1121 } 1122 #endif 1072 1123 deleteInL(strat->B,&strat->Bl,j,strat); 1073 1124 strat->c3++; 1074 1125 } 1075 1126 } 1076 if (compare == pDivComp_EQUAL) 1077 { 1078 // Add hint for same LM and direction of LC (later) (TODO Oliver) 1127 if ((compare == pDivComp_EQUAL) && (compareCoeff != 2)) 1128 { 1079 1129 if (compareCoeff == pDivComp_LESS) 1080 1130 { 1131 #ifdef KDEBUG 1132 if (TEST_OPT_DEBUG) 1133 { 1134 PrintS("--- chain criterion type 3\n"); 1135 Print("strat->B[%d].lcm:", j); 1136 wrp(strat->B[j].lcm); 1137 PrintS(" Lp.lcm:"); 1138 wrp(Lp.lcm); 1139 PrintLn(); 1140 } 1141 #endif 1081 1142 strat->c3++; 1082 1143 if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) … … 1088 1149 } 1089 1150 else 1090 if (compareCoeff == pDivComp_GREATER) 1091 { 1151 // Add hint for same LM and LC (later) (TODO Oliver) 1152 // if (compareCoeff == pDivComp_GREATER) 1153 { 1154 #ifdef KDEBUG 1155 if (TEST_OPT_DEBUG) 1156 { 1157 PrintS("--- chain criterion type 4\n"); 1158 Print("strat->B[%d].lcm:", j); 1159 wrp(strat->B[j].lcm); 1160 PrintS(" Lp.lcm:"); 1161 wrp(Lp.lcm); 1162 PrintLn(); 1163 } 1164 #endif 1092 1165 deleteInL(strat->B,&strat->Bl,j,strat); 1093 1166 strat->c3++; … … 1099 1172 */ 1100 1173 /*- compute the short s-polynomial -*/ 1101 if ((strat->S[i]==NULL) || (p==NULL)) return; 1174 if ((strat->S[i]==NULL) || (p==NULL)) { 1175 #ifdef KDEBUG 1176 if (TEST_OPT_DEBUG) 1177 { 1178 PrintS("--- spoly = NULL\n"); 1179 } 1180 #endif 1181 return; 1182 } 1102 1183 pNorm(p); 1103 1184 if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0)) … … 1113 1194 if (Lp.p == NULL) 1114 1195 { 1196 #ifdef KDEBUG 1197 if (TEST_OPT_DEBUG) 1198 { 1199 PrintS("--- spoly = NULL\n"); 1200 } 1201 #endif 1115 1202 /*- the case that the s-poly is 0 -*/ 1116 1203 if (strat->pairtest==NULL) initPairtest(strat); … … 1145 1232 l = strat->posInL(strat->B,strat->Bl,&Lp,strat); 1146 1233 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l); 1234 } 1235 } 1236 1237 1238 /*2 1239 * put the lcm(s[i],p) into the set B 1240 */ 1241 1242 #include <NTL/ZZ.h> 1243 #ifdef NTL_CLIENT 1244 NTL_CLIENT 1245 #endif 1246 1247 void enterOneStrongPoly (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = -1) 1248 { 1249 long d, s, t; 1250 assume(i<=strat->sl); 1251 LObject Lp; 1252 poly m1, m2, erg, gcd; 1253 1254 XGCD(d, s, t, (long) pGetCoeff(p), (long) pGetCoeff(strat->S[i])); 1255 1256 1257 k_GetStrongLeadTerms(p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing); 1258 1259 pSetCoeff0(m1, (number) t); 1260 pSetCoeff0(m2, (number) s); 1261 pSetCoeff0(gcd, (number) d); 1262 1263 1264 #ifdef KDEBUG 1265 if (TEST_OPT_DEBUG) 1266 { 1267 Print("t = %d; s = %d; d = %d\n", t, s, d); 1268 PrintS("--- create strong gcd poly: "); 1269 wrp(p); 1270 Print("\n strat->S[%d]: ", i); 1271 wrp(strat->S[i]); 1272 PrintS(" ---> "); 1273 } 1274 #endif 1275 1276 erg = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(strat->S[i]), m2, strat->tailRing), strat->tailRing); 1277 pNext(gcd) = erg; 1278 1279 #ifdef KDEBUG 1280 if (TEST_OPT_DEBUG) 1281 { 1282 wrp(gcd); 1283 PrintLn(); 1284 } 1285 #endif 1286 1287 LObject h; 1288 h.p = gcd; 1289 h.tailRing = strat->tailRing; 1290 int posx; 1291 if (h.p!=NULL) 1292 { 1293 if (TEST_OPT_INTSTRATEGY) 1294 { 1295 h.pCleardenom(); // also does a pContent 1296 } 1297 else 1298 { 1299 h.pNorm(); 1300 } 1301 strat->initEcart(&h); 1302 if (strat->Ll==-1) 1303 posx =0; 1304 else 1305 posx = strat->posInL(strat->L,strat->Ll,&h,strat); 1306 h.sev = pGetShortExpVector(h.p); 1307 h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing); 1308 if (pNext(p) != NULL) 1309 { 1310 // What does this? (Oliver) 1311 // pShallowCopyDeleteProc p_shallow_copy_delete 1312 // = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing); 1313 // pNext(p) = p_shallow_copy_delete(pNext(p), 1314 // currRing, strat->tailRing, strat->tailRing->PolyBin); 1315 } 1316 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx); 1147 1317 } 1148 1318 } … … 1799 1969 if (pDivisibleBy(strat->S[j],strat->B[i].lcm)) 1800 1970 { 1971 #ifdef KDEBUG 1972 if (TEST_OPT_DEBUG) 1973 { 1974 PrintS("--- chain criterion func chainCritRing type 1\n"); 1975 PrintS("strat->S[j]:"); 1976 wrp(strat->S[j]); 1977 PrintS(" strat->B[i].lcm:"); 1978 wrp(strat->B[i].lcm); 1979 PrintLn(); 1980 } 1981 #endif 1801 1982 deleteInL(strat->B,&strat->Bl,i,strat); 1802 1983 strat->c3++; … … 1812 1993 for (j=strat->Ll; j>=0; j--) 1813 1994 { 1814 if (strat->L[j].lcm != NULL && n Greater(pGetCoeff(strat->L[j].lcm), pGetCoeff(p)))1995 if (strat->L[j].lcm != NULL && nDivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(p))) 1815 1996 { 1816 1997 if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm)) … … 1820 2001 deleteInL(strat->L,&strat->Ll,j,strat); 1821 2002 strat->c3++; 1822 // Print("|UL|"); 2003 #ifdef KDEBUG 2004 if (TEST_OPT_DEBUG) 2005 { 2006 PrintS("--- chain criterion func chainCritRing type 2\n"); 2007 PrintS("strat->L[j].p:"); 2008 wrp(strat->L[j].p); 2009 PrintS(" p:"); 2010 wrp(p); 2011 PrintLn(); 2012 } 2013 #endif 1823 2014 } 1824 2015 } … … 1861 2052 if (i < 0) break; 1862 2053 // Element is from B and has the same lcm as L[j] 1863 if ((strat->L[i].p2 == p) && n Greater(pGetCoeff(strat->L[j].lcm), pGetCoeff(strat->L[i].lcm))2054 if ((strat->L[i].p2 == p) && nDivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(strat->L[i].lcm)) 1864 2055 && pLmEqual(strat->L[j].lcm,strat->L[i].lcm)) 1865 2056 { 1866 2057 /*L[i] could be canceled but we search for a better one to cancel*/ 1867 2058 strat->c3++; 1868 // Print("|EP|"); 2059 #ifdef KDEBUG 2060 if (TEST_OPT_DEBUG) 2061 { 2062 PrintS("--- chain criterion func chainCritRing type 3\n"); 2063 PrintS("strat->L[j].lcm:"); 2064 wrp(strat->L[j].lcm); 2065 PrintS(" strat->L[i].lcm:"); 2066 wrp(strat->L[i].lcm); 2067 PrintLn(); 2068 } 2069 #endif 1869 2070 if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat) 1870 2071 && (pNext(strat->L[l].p) == strat->tail) … … 2336 2537 { 2337 2538 new_pair=TRUE; 2539 Print("TODO Oliver --- j:%d, Ll:%d\n",j,strat->Ll); 2338 2540 enterOnePairRing(j,h,ecart,isFromQ,strat, atR); 2339 Print("j:%d, Ll:%d\n",j,strat->Ll);2340 2541 } 2341 2542 } … … 2346 2547 for (j=0; j<=k; j++) 2347 2548 { 2549 // Print("j:%d, Ll:%d\n",j,strat->Ll); 2348 2550 enterOnePairRing(j,h,ecart,isFromQ,strat, atR); 2349 // Print("j:%d, Ll:%d\n",j,strat->Ll);2350 2551 } 2351 2552 } … … 2358 2559 { 2359 2560 new_pair=TRUE; 2561 Print("TODO Oliver --- j:%d, Ll:%d\n",j,strat->Ll); 2360 2562 enterOnePairRing(j,h,ecart,isFromQ,strat, atR); 2361 Print("j:%d, Ll:%d\n",j,strat->Ll);2362 2563 } 2363 2564 } … … 2370 2571 if (new_pair) chainCritRing(h,ecart,strat); 2371 2572 2573 } 2574 /* 2575 ring r=256,(x,y,z),dp; 2576 ideal I=12xz-133y, 2xy-z; 2577 */ 2578 2579 } 2580 2581 /*2 2582 *(s[0],h),...,(s[k],h) will be put to the pairset L 2583 */ 2584 void initenterstrongPairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1) 2585 { 2586 2587 if (!nIsOne(pGetCoeff(h))) 2588 { 2589 int j; 2590 BOOLEAN new_pair=FALSE; 2591 2592 for (j=0; j<=k; j++) 2593 { 2594 // Print("j:%d, Ll:%d\n",j,strat->Ll); 2595 if (((unsigned long) pGetCoeff(h) % (unsigned long) pGetCoeff(strat->S[j]) != 0) && 2596 ((unsigned long) pGetCoeff(strat->S[j]) % (unsigned long) pGetCoeff(h) != 0)) 2597 { 2598 new_pair=TRUE; 2599 enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR); 2600 } 2601 } 2372 2602 } 2373 2603 /* … … 2403 2633 PrintS("Z"); 2404 2634 } 2635 #ifdef KDEBUG 2636 if (TEST_OPT_DEBUG) 2637 { 2638 PrintS("--- create zero spoly: "); 2639 wrp(h); 2640 PrintS(" ---> "); 2641 } 2642 #endif 2405 2643 poly tmp = p_ISet((long) ((p)->coef), currRing); 2406 2644 for (int i = 1; i <= currRing->N; i++) … … 2442 2680 // currRing, strat->tailRing, strat->tailRing->PolyBin); 2443 2681 } 2682 #ifdef KDEBUG 2683 if (TEST_OPT_DEBUG) 2684 { 2685 wrp(tmp); 2686 PrintLn(); 2687 } 2688 #endif 2444 2689 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx); 2445 2690 } … … 2456 2701 )) 2457 2702 { 2458 // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);2703 // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl); 2459 2704 unsigned long h_sev = pGetShortExpVector(h); 2460 2705 loop … … 2464 2709 j++; 2465 2710 } 2466 // Print("end clearS sl=%d\n",strat->sl);2711 // Print("end clearS sl=%d\n",strat->sl); 2467 2712 } 2468 2713 } … … 2478 2723 enterExtendedSpoly(h, strat); 2479 2724 initenterpairsRing(h, k, ecart, 0, strat, atR); 2725 initenterstrongPairs(h, k, ecart, 0, strat, atR); 2480 2726 clearSbatch(h, k, pos, strat); 2481 2727 } … … 2490 2736 int j=pos; 2491 2737 2738 assume (!rField_is_Ring(currRing)); 2492 2739 initenterpairs(h,k,ecart,0,strat, atR); 2493 2740 if ( (!strat->fromT) -
kernel/kutil.h
r1591a87 rd681e8 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1.2 3 2007-05-11 10:48:04wienand Exp $ */6 /* $Id: kutil.h,v 1.24 2007-05-19 13:22:22 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 493 493 KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, 494 494 poly &m1, poly &m2, const ring m_r); 495 #ifdef HAVE_RINGS 496 KINLINE BOOLEAN k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, 497 poly &m1, poly &m2, poly &lcm, const ring taiRing); 498 #endif 495 499 #ifdef KDEBUG 496 500 // test strat -
kernel/polys.cc
r1591a87 rd681e8 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.1 7 2007-05-11 10:48:04wienand Exp $ */4 /* $Id: polys.cc,v 1.18 2007-05-19 13:22:23 wienand Exp $ */ 5 5 6 6 /* … … 691 691 #ifdef HAVE_RINGS //HACK TODO Oliver 692 692 number nGetUnit(number k) { 693 return (number) nIntDiv(k, nGcd(k, 0, currRing)); 693 number unit = nIntDiv(k, nGcd(k, 0, currRing)); 694 number gcd = nGcd(unit, 0, currRing); 695 if (!nIsOne(gcd)) 696 { 697 number tmp = nMult(unit, unit); 698 number gcd_new = nGcd(tmp, 0, currRing); 699 while (gcd_new != gcd) 700 { 701 gcd = gcd_new; 702 tmp = nMult(tmp, unit); 703 gcd_new = nGcd(tmp, 0, currRing); 704 } 705 unit = nAdd(unit, nIntDiv(0, gcd_new)); 706 } 707 return unit; 694 708 } 695 709 #endif -
kernel/rmodulo2m.cc
r1591a87 rd681e8 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulo2m.cc,v 1. 9 2007-05-11 10:48:05wienand Exp $ */4 /* $Id: rmodulo2m.cc,v 1.10 2007-05-19 13:22:23 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo 2^m … … 300 300 if ((NATNUMBER)b==0) 301 301 return (number) 1; 302 if ((NATNUMBER)b==1) 303 return (number) 0; 302 304 return (number) (nr2mModul / (NATNUMBER) b); 303 305 } -
kernel/rmodulon.cc
r1591a87 rd681e8 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulon.cc,v 1. 3 2007-05-11 10:48:05wienand Exp $ */4 /* $Id: rmodulon.cc,v 1.4 2007-05-19 13:22:23 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo n … … 77 77 number nrnLcm (number a,number b,ring r) 78 78 { 79 return (number) (XSGCD2(nrnModul, (NATNUMBER) a) * XSGCD2(nrnModul, (NATNUMBER) b) / XSGCD3(nrnModul, (NATNUMBER) a, (NATNUMBER) b)); 79 NATNUMBER erg = XSGCD2(nrnModul, (NATNUMBER) a) * XSGCD2(nrnModul, (NATNUMBER) b) / XSGCD3(nrnModul, (NATNUMBER) a, (NATNUMBER) b); 80 if (erg == nrnModul) return NULL; // Schneller als return erg % nrnModul ? 81 return (number) erg; 80 82 } 81 83 … … 167 169 NATNUMBER as = XSGCD2((NATNUMBER) a, nrnModul); 168 170 if (bs == as) return 0; 169 if (as % bs == 0) return 1; 170 return -1; 171 if (as % bs == 0) return -1; 172 if (bs % as == 0) return 1; 173 return 2; 171 174 } 172 175 … … 278 281 if ((NATNUMBER)b==0) 279 282 return (number) 1; 283 if ((NATNUMBER)b==1) 284 return (number) 0; 280 285 return (number) ( nrnModul / (NATNUMBER) b); 281 286 }
Note: See TracChangeset
for help on using the changeset viewer.