Changeset 30fb427 in git
- Timestamp:
- Aug 5, 1998, 1:40:58 PM (26 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 0e3e6f4a4d841a9a31f2a0c9f797ac572094c852
- Parents:
- d950c52d07929c4629546c9ad477819d8410ffb3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/syz1.cc
rd950c5 r30fb427 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: syz1.cc,v 1.3 0 1998-06-30 14:48:20 obachmanExp $ */4 /* $Id: syz1.cc,v 1.31 1998-08-05 11:40:58 siebert Exp $ */ 5 5 /* 6 6 * ABSTRACT: resolutions … … 1036 1036 } 1037 1037 1038 /*3 1039 * reduces all pairs of degree deg in the module index 1040 * put the reduced generators to the resolvente which contains 1041 * the truncated kStd 1042 */ 1043 static void syRedNextPairs(SSet nextPairs, syStrategy syzstr, 1044 int howmuch, int index) 1045 { 1046 int i=howmuch-1,j,k=IDELEMS(syzstr->res[index]); 1047 int ks=IDELEMS(syzstr->res[index+1]),kk,l,ll; 1038 //#define OLD_PAIR_ORDER 1039 #ifdef OLD_PAIR_ORDER 1040 static intvec* syLinStrat(SSet nextPairs, syStrategy syzstr, 1041 int howmuch, int index) 1042 { 1043 int i=howmuch-1,i1=0,l,ll; 1048 1044 int ** Fin=syzstr->Firstelem; 1049 1045 int ** Hin=syzstr->Howmuch; 1050 1046 int ** bin=syzstr->backcomponents; 1051 number coefgcd,n;1052 1047 ideal o_r=syzstr->orderedRes[index+1]; 1053 polyset redset=syzstr->orderedRes[index]->m; 1054 poly p=NULL,q; 1048 intvec *result=new intvec(howmuch+1); 1055 1049 BOOLEAN isDivisible; 1056 1050 SObject tso; 1057 1051 1058 if ((nextPairs==NULL) || (howmuch==0)) return;1059 while ((k>0) && (syzstr->res[index]->m[k-1]==NULL)) k--;1060 while ((ks>0) && (syzstr->res[index+1]->m[ks-1]==NULL)) ks--;1061 1052 while (i>=0) 1062 1053 { … … 1080 1071 } 1081 1072 } 1082 if (!isDivisible) 1083 { 1084 tso.p = 1073 if (isDivisible) 1074 { 1075 syDeletePair(&nextPairs[i]); 1076 //crit++; 1077 } 1078 else 1079 { 1080 nextPairs[i].p = 1085 1081 sySPoly(tso.p1, tso.p2,tso.lcm); 1082 (*result)[i1] = i+1; 1083 i1++; 1084 } 1085 i--; 1086 } 1087 return result; 1088 } 1089 #else 1090 static intvec* syLinStrat(SSet nextPairs, syStrategy syzstr, 1091 int howmuch, int index) 1092 { 1093 int i=howmuch-1,i1=0,i2,i3,l,ll; 1094 int ** Fin=syzstr->Firstelem; 1095 int ** Hin=syzstr->Howmuch; 1096 int ** bin=syzstr->backcomponents; 1097 ideal o_r=syzstr->orderedRes[index+1]; 1098 intvec *result=new intvec(howmuch+1); 1099 intvec *spl=new intvec(howmuch,1,-1); 1100 BOOLEAN isDivisible; 1101 SObject tso; 1102 1103 while (i>=0) 1104 { 1105 tso = nextPairs[i]; 1106 isDivisible = FALSE; 1107 if (syzstr->res[index+1]!=NULL) 1108 { 1109 l = Fin[index][pGetComp(tso.lcm)]-1; 1110 if (l>=0) 1111 { 1112 ll = l+Hin[index][pGetComp(tso.lcm)]; 1113 while ((l<ll) && (!isDivisible)) 1114 { 1115 if (o_r->m[l]!=NULL) 1116 { 1117 isDivisible = isDivisible || 1118 pDivisibleBy2(o_r->m[l],tso.lcm); 1119 } 1120 l++; 1121 } 1122 } 1123 } 1124 if (isDivisible) 1125 { 1126 syDeletePair(&nextPairs[i]); 1127 //crit++; 1128 } 1129 else 1130 { 1131 nextPairs[i].p = 1132 sySPoly(tso.p1, tso.p2,tso.lcm); 1133 (*spl)[i] = pLength(nextPairs[i].p); 1134 } 1135 i--; 1136 } 1137 //Print("\n");Print("Laengenvektor: ");spl->show(1,1);Print("\n"); 1138 i3 = 0; 1139 loop 1140 { 1141 i2 = -1; 1142 for (i1=0;i1<howmuch;i1++) 1143 { 1144 if (i2==-1) 1145 { 1146 if ((*spl)[i1]!=-1) 1147 { 1148 i2 = i1; 1149 } 1150 } 1151 else 1152 { 1153 if (((*spl)[i1]>=0) && ((*spl)[i1]<(*spl)[i2])) 1154 { 1155 i2 = i1; 1156 } 1157 } 1158 } 1159 if (i2>=0) 1160 { 1161 (*result)[i3] = i2+1; 1162 (*spl)[i2] = -1; 1163 i3++; 1164 } 1165 else 1166 { 1167 break; 1168 } 1169 } 1170 return result; 1171 } 1172 #endif 1173 /*3 1174 * reduces all pairs of degree deg in the module index 1175 * put the reduced generators to the resolvente which contains 1176 * the truncated kStd 1177 */ 1178 static void syRedNextPairs(SSet nextPairs, syStrategy syzstr, 1179 int howmuch, int index) 1180 { 1181 int i,j,k=IDELEMS(syzstr->res[index]); 1182 int ks=IDELEMS(syzstr->res[index+1]),kk,l,ll; 1183 int ** Fin=syzstr->Firstelem; 1184 int ** Hin=syzstr->Howmuch; 1185 int ** bin=syzstr->backcomponents; 1186 number coefgcd,n; 1187 polyset redset=syzstr->orderedRes[index]->m; 1188 poly p=NULL,q; 1189 intvec *spl1=new intvec(howmuch+1); 1190 SObject tso; 1191 1192 if ((nextPairs==NULL) || (howmuch==0)) return; 1193 while ((k>0) && (syzstr->res[index]->m[k-1]==NULL)) k--; 1194 while ((ks>0) && (syzstr->res[index+1]->m[ks-1]==NULL)) ks--; 1195 spl1 = syLinStrat(nextPairs,syzstr,howmuch,index); 1196 //Print("\n");Print("Ordnungsvektor: ");spl1->show(1,1);Print("\n"); 1197 i=0; 1198 while ((*spl1)[i]>0) 1199 { 1200 tso = nextPairs[(*spl1)[i]-1]; 1201 if ((tso.p1!=NULL) && (tso.p2!=NULL)) 1202 { 1086 1203 coefgcd = 1087 nGcd(pGetCoeff(tso.p1),pGetCoeff(tso.p 1));1204 nGcd(pGetCoeff(tso.p1),pGetCoeff(tso.p2)); 1088 1205 tso.syz = pHead(tso.lcm); 1089 1206 pSetm(tso.syz); … … 1232 1349 ks++; 1233 1350 p = NULL; 1234 nextPairs[i] = tso; 1235 } 1236 else 1237 { 1238 syDeletePair(&nextPairs[i]); 1239 //crit++; 1240 } 1241 i--; 1242 } 1351 nextPairs[(*spl1)[i]-1] = tso; 1352 } 1353 i++; 1354 } 1355 delete spl1; 1243 1356 } 1244 1357 … … 1437 1550 { 1438 1551 pDelete(&(nPm[j1])); 1439 break;1552 //break; 1440 1553 } 1441 1554 } … … 1502 1615 } 1503 1616 1617 /*2 1618 * tail reduction for the LaScala algorithm 1619 * takes care of the special ordering 1620 */ 1504 1621 static void sySyzTail(syStrategy syzstr, int index, int newEl) 1505 1622 { … … 1819 1936 } 1820 1937 1938 /*3 1939 * deletes a resolution 1940 */ 1821 1941 void syKillComputation(syStrategy syzstr) 1822 1942 { … … 1935 2055 } 1936 2056 2057 /*3 2058 * read out the Betti numbers from resolution 2059 * (if not LaScala calls the traditional Betti procedure) 2060 */ 1937 2061 intvec * syBettiOfComputation(syStrategy syzstr) 1938 2062 { … … 1986 2110 } 1987 2111 2112 /*3 2113 * computes the allocated length of the resolution 2114 */ 1988 2115 int syLength(syStrategy syzstr) 1989 2116 { … … 1991 2118 } 1992 2119 2120 /*3 2121 * computes the real length of the resolution 2122 */ 1993 2123 int sySize(syStrategy syzstr) 1994 2124 { … … 2008 2138 } 2009 2139 2140 /*3 2141 * computes the cohomological dimension of res[1] 2142 */ 2010 2143 int syDim(syStrategy syzstr) 2011 2144 { … … 2040 2173 } 2041 2174 2175 /*3 2176 * copies the resolution (by increment the reference counter) 2177 */ 2042 2178 syStrategy syCopy(syStrategy syzstr) 2043 2179 { … … 2047 2183 } 2048 2184 2185 /*2 2186 * local print procedure used in syPrint 2187 */ 2049 2188 static void syPrintEmptySpaces(int i) 2050 2189 { … … 2056 2195 } 2057 2196 2197 /*2 2198 * local print procedure used in syPrint 2199 */ 2058 2200 static void syPrintEmptySpaces1(int i) 2059 2201 { … … 2065 2207 } 2066 2208 2209 /*2 2210 * local print procedure used in syPrint 2211 */ 2067 2212 static int syLengthInt(int i) 2068 2213 { … … 2078 2223 } 2079 2224 2225 /*3 2226 * prints the resolution as sequence of free modules 2227 */ 2080 2228 void syPrint(syStrategy syzstr) 2081 2229 { … … 2169 2317 } 2170 2318 2319 /*2 2320 * divides out the weight monomials (given by the Schreyer-ordering) 2321 * fronm the LaScala-resolution 2322 */ 2171 2323 static resolvente syReorder(resolvente res,int length, 2172 2324 syStrategy syzstr,BOOLEAN toCopy=TRUE,resolvente totake=NULL) … … 2231 2383 } 2232 2384 2385 /*3 2386 * converts a resolution into a list of modules 2387 */ 2233 2388 lists syConvRes(syStrategy syzstr) 2234 2389 { … … 2269 2424 } 2270 2425 2426 /*3 2427 * converts a list of modules into a resolution 2428 */ 2271 2429 syStrategy syConvList(lists li) 2272 2430 { … … 2286 2444 } 2287 2445 2446 /*3 2447 * converts a list of modules into a minimal resolution 2448 */ 2288 2449 syStrategy syForceMin(lists li) 2289 2450 { … … 2302 2463 } 2303 2464 2465 /*2 2466 * deleting all monomials the component of which correspond 2467 * to non-minimal generators 2468 */ 2304 2469 static poly syStripOut(poly p,intvec * toStrip) 2305 2470 { … … 2323 2488 } 2324 2489 2325 static poly syMinimizeP( poly toMin,syStrategy syzstr,int pNum,int index,2490 static poly syMinimizeP(int toMin,syStrategy syzstr,intvec * ordn,int index, 2326 2491 intvec * toStrip) 2327 2492 { 2328 int i ,j,tc,lastin,newin=pNum-1;2329 poly p,pp =pCopy(toMin),q=NULL,tq,pisN;2493 int ii=0,i,j,tc; 2494 poly p,pp,q=NULL,tq,pisN; 2330 2495 SSet sPairs=syzstr->resPairs[index]; 2331 2496 poly tempStripped=NULL; 2497 2498 pp=pCopy(syzstr->res[index+1]->m[toMin]); 2332 2499 pp = syStripOut(pp,toStrip); 2333 while (newin>=0) 2334 { 2335 lastin = newin; 2336 while ((newin>=0) && (sPairs[lastin].order==sPairs[newin].order)) 2337 newin--; 2338 //Print("Hier lastin:%d newin:%d\n",lastin,newin); 2339 for (i=newin+1;i<=lastin;i++) 2340 { 2341 if (sPairs[i].isNotMinimal!=NULL) 2342 { 2343 pisN = sPairs[i].isNotMinimal; 2344 tc = pGetComp(pisN); 2345 p = pp; 2346 while (p!=NULL) 2347 { 2348 if (pGetComp(p)==tc) 2349 { 2350 tq = pInit(); 2351 for(j=pVariables; j>0; j--) 2352 pSetExp(tq,j, pGetExp(p,j)-pGetExp(pisN,j)); 2353 pSetComp(tq, 0); 2354 pSetCoeff0(tq,nDiv(pGetCoeff(p),pGetCoeff(pisN))); 2355 pGetCoeff(tq) = nNeg(pGetCoeff(tq)); 2356 q = syAdd(q,syStripOut(syMultT1(syzstr->res[index+1]->m[sPairs[i].syzind],tq),toStrip)); 2357 } 2358 pIter(p); 2359 } 2360 if (q!=NULL) 2361 { 2362 pp = syAdd(pp,q); 2363 q = NULL; 2364 } 2365 } 2366 } 2500 while ((ii<ordn->length()) && ((*ordn)[ii]!=-1) && (sPairs[(*ordn)[ii]].syzind!=toMin)) 2501 { 2502 ii++; 2503 } 2504 while (ii>=0) 2505 { 2506 i = (*ordn)[ii]; 2507 if (sPairs[i].isNotMinimal!=NULL) 2508 { 2509 tempStripped = syStripOut(pCopy(syzstr->res[index+1]->m[sPairs[i].syzind]),toStrip); 2510 pisN = sPairs[i].isNotMinimal; 2511 tc = pGetComp(pisN); 2512 p = pp; 2513 while (p!=NULL) 2514 { 2515 if (pGetComp(p)==tc) 2516 { 2517 tq = pInit(); 2518 for(j=pVariables; j>0; j--) 2519 pSetExp(tq,j, pGetExp(p,j)-pGetExp(pisN,j)); 2520 pSetComp(tq, 0); 2521 pSetCoeff0(tq,nDiv(pGetCoeff(p),pGetCoeff(pisN))); 2522 pGetCoeff(tq) = nNeg(pGetCoeff(tq)); 2523 q = syAdd(q,syMultT1(tempStripped,tq)); 2524 } 2525 pIter(p); 2526 } 2527 if (q!=NULL) 2528 { 2529 pp = syAdd(pp,q); 2530 q = NULL; 2531 } 2532 pDelete(&tempStripped); 2533 } 2534 ii--; 2367 2535 } 2368 2536 return pp; … … 2435 2603 } 2436 2604 2605 static intvec * syOrdPairs(SSet sPairs, int length) 2606 { 2607 intvec * result=new intvec(length,1,-1); 2608 int i,j=0,k=-1,l,ii; 2609 2610 loop 2611 { 2612 l = -1; 2613 for(i=0;i<length;i++) 2614 { 2615 if (sPairs[i].syzind>k) 2616 { 2617 if (l==-1) 2618 { 2619 l = sPairs[i].syzind; 2620 ii = i; 2621 } 2622 else 2623 { 2624 if (sPairs[i].syzind<l) 2625 { 2626 l = sPairs[i].syzind; 2627 ii = i; 2628 } 2629 } 2630 } 2631 } 2632 if (l==-1) break; 2633 (*result)[j] = ii; 2634 j++; 2635 k = l; 2636 } 2637 return result; 2638 } 2639 2437 2640 static resolvente syReadOutMinimalRes(syStrategy syzstr, 2438 2641 BOOLEAN computeStd=FALSE) 2439 2642 { 2440 intvec * Strip ;2643 intvec * Strip, * ordn; 2441 2644 resolvente tres=(resolvente)Alloc0((syzstr->length+1)*sizeof(ideal)); 2442 2645 sip_sring tmpR; … … 2449 2652 return tres; 2450 2653 } 2451 int i,j,l,index, o1,ii,i1;2654 int i,j,l,index,ii,i1; 2452 2655 poly p; 2453 2656 ideal rs; … … 2496 2699 tres[index+1] = idInit(IDELEMS(syzstr->res[index+1]),syzstr->res[index+1]->rank); 2497 2700 i1 = (*syzstr->Tl)[index]; 2701 ordn = syOrdPairs(sPairs,i1); 2498 2702 for (i=0;i<i1;i++) 2499 2703 { 2500 2704 if ((sPairs[i].isNotMinimal==NULL) && (sPairs[i].lcm!=NULL)) 2501 2705 { 2502 o1 = sPairs[i].order;2503 ii = i;2504 while ((ii<i1) && (sPairs[ii].lcm!=NULL) && (sPairs[ii].order==o1))2505 ii++;2506 2706 l = sPairs[i].syzind; 2507 2707 tres[index+1]->m[l] = 2508 syMinimizeP( syzstr->res[index+1]->m[l],syzstr,ii,index,Strip);2708 syMinimizeP(l,syzstr,ordn,index,Strip); 2509 2709 } 2510 2710 }
Note: See TracChangeset
for help on using the changeset viewer.