Changeset e960943 in git
- Timestamp:
- Oct 14, 1999, 2:50:29 PM (25 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- b7b08cbfc7838d9595098d9d8994e6a44848ba40
- Parents:
- 9a384e219388c1607b367164a5297b9e011b6589
- Location:
- Singular
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
r9a384e re960943 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.10 8 1999-09-29 10:59:28 obachmanExp $ */4 /* $Id: extra.cc,v 1.109 1999-10-14 12:50:25 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 488 488 int j; 489 489 PrintS("varoffset:\n"); 490 #ifdef HAVE_SHIFTED_EXPONENTS 491 for(j=0;j<=r->N;j++) Print(" v%d at pos %d, bit %d\n", 492 j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24); 493 Print("bitmask=%x\n",r->bitmask); 494 #else 490 495 for(j=0;j<=r->N;j++) Print(" v%d at pos %d\n",j,r->VarOffset[j]); 496 #endif 491 497 PrintS("ordsgn:\n"); 492 498 for(j=0;j<r->pCompLSize;j++) -
Singular/ideals.cc
r9a384e re960943 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.5 6 1999-09-27 13:51:05 obachmanExp $ */4 /* $Id: ideals.cc,v 1.57 1999-10-14 12:50:25 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 1076 1076 } 1077 1077 temp = idInit(IDELEMS(first),1); 1078 j = IDELEMS(temp); 1078 j = IDELEMS(first); 1079 1080 ring orig_ring=currRing; 1081 ring syz_ring=rAddSyzComp(currRing); 1082 pSetSyzComp(length); 1083 1079 1084 while ((j>0) && (first->m[j-1]==NULL)) j--; 1080 1085 k = 0; … … 1083 1088 if (first->m[i]!=NULL) 1084 1089 { 1085 temp->m[k] = pCopy(first->m[i]); 1090 if (syz_ring==orig_ring) 1091 temp->m[k] = pCopy(first->m[i]); 1092 else 1093 temp->m[k] = pPermPoly(first->m[i],NULL,orig_ring,NULL,0); 1086 1094 q = pOne(); 1087 1095 pSetComp(q,i+1+length); … … 1099 1107 if (second->m[i]!=NULL) 1100 1108 { 1101 temp->m[k] = pCopy(second->m[i]); 1109 if (syz_ring==orig_ring) 1110 temp->m[k] = pCopy(second->m[i]); 1111 else 1112 temp->m[k] = pPermPoly(second->m[i],NULL,orig_ring,NULL,0); 1102 1113 if (slength==0) pShift(&(temp->m[k]),1); 1103 1114 k++; 1104 1115 } 1105 1116 } 1106 pSetSyzComp(length);1107 1117 temp1 = kStd(temp,currQuotient,testHomog,&w,NULL,length); 1108 1118 if (w!=NULL) delete w; 1119 idDelete(&temp); 1120 1121 if(syz_ring!=orig_ring) 1122 rChangeCurrRing(orig_ring,TRUE); 1109 1123 pSetSyzComp(0); 1110 idDelete(&temp); 1124 1111 1125 result = idInit(IDELEMS(temp1),rank); 1112 1126 j = 0; … … 1114 1128 { 1115 1129 if ((temp1->m[i]!=NULL) 1116 && (pGetComp(temp1->m[i])>length)) 1117 { 1118 p = temp1->m[i]; 1119 //PrintS("die Syzygie ist: ");pWrite(p); 1120 temp1->m[i] = NULL; 1130 && (pRingGetComp(syz_ring,temp1->m[i])>length)) 1131 { 1132 if(syz_ring==orig_ring) 1133 p = pCopy(temp1->m[i]); 1134 else 1135 p = pPermPoly(temp1->m[i],NULL,syz_ring,NULL,0); 1121 1136 while (p!=NULL) 1122 1137 { … … 1125 1140 k = pGetComp(p)-1-length; 1126 1141 pSetComp(p,0); 1127 //PrintS("das %d-te Element: ",k);pWrite(first->m[k]);1128 1142 result->m[j] = pAdd(result->m[j],pMult(pCopy(first->m[k]),p)); 1129 1143 p = q; 1130 1144 } 1131 //PrintS("Generator ist: ");pWrite(result->m[j]);1132 1145 j++; 1133 1146 } 1134 1147 } 1148 if(syz_ring!=orig_ring) 1149 rChangeCurrRing(syz_ring,FALSE); 1150 idDelete(&temp1); 1151 if(syz_ring!=orig_ring) 1152 rChangeCurrRing(orig_ring,TRUE); 1153 if(syz_ring!=orig_ring) 1154 rKill(syz_ring); 1155 1135 1156 idSkipZeroes(result); 1136 1157 return result; … … 1174 1195 /* init -----------------------------------------------------------*/ 1175 1196 j += maxrk; 1197 syzComp = k*maxrk; 1198 ring orig_ring=currRing; 1199 ring syz_ring=rAddSyzComp(currRing); 1200 pSetSyzComp(syzComp); 1201 1176 1202 bigmat = idInit(j,(k+1)*maxrk); 1177 syzComp = k*maxrk;1178 pSetSyzComp(syzComp);1179 1203 /* create unit matrices ------------------------------------------*/ 1180 1204 for (i=0;i<maxrk;i++) … … 1199 1223 if (arg[j]->m[l]!=NULL) 1200 1224 { 1201 bigmat->m[i] = pCopy(arg[j]->m[l]); 1225 if (syz_ring==orig_ring) 1226 bigmat->m[i] = pCopy(arg[j]->m[l]); 1227 else 1228 bigmat->m[i] = pPermPoly(arg[j]->m[l],NULL,orig_ring,NULL,0); 1202 1229 pShift(&(bigmat->m[i]),k*maxrk+isIdeal); 1203 1230 i++; … … 1211 1238 if (w!=NULL) delete w; 1212 1239 idDelete(&bigmat); 1240 1241 if(syz_ring!=orig_ring) 1242 rChangeCurrRing(orig_ring,TRUE); 1213 1243 pSetSyzComp(0); 1244 1214 1245 /* interprete result ----------------------------------------*/ 1215 1246 result = idInit(8,maxrk); … … 1217 1248 for (j=0;j<IDELEMS(tempstd);j++) 1218 1249 { 1219 if ((tempstd->m[j]!=NULL) && (p GetComp(tempstd->m[j])>syzComp))1250 if ((tempstd->m[j]!=NULL) && (pRingGetComp(syz_ring,tempstd->m[j])>syzComp)) 1220 1251 { 1221 1252 if (k>=IDELEMS(result)) … … 1224 1255 IDELEMS(result) += 8; 1225 1256 } 1226 p = tempstd->m[j]; 1227 tempstd->m[j] = NULL; 1257 if (syz_ring==orig_ring) 1258 p = pCopy(tempstd->m[j]); 1259 else 1260 p = pPermPoly(tempstd->m[j],NULL,syz_ring,NULL,0); 1228 1261 pShift(&p,-syzComp-isIdeal); 1229 1262 result->m[k] = p; … … 1232 1265 } 1233 1266 /* clean up ----------------------------------------------------*/ 1267 if(syz_ring!=orig_ring) 1268 rChangeCurrRing(syz_ring,FALSE); 1234 1269 idDelete(&tempstd); 1270 if(syz_ring!=orig_ring) 1271 { 1272 rChangeCurrRing(orig_ring,TRUE); 1273 rKill(syz_ring); 1274 } 1235 1275 idSkipZeroes(result); 1236 1276 return result; … … 1257 1297 *computes syzygies of h1, 1258 1298 *if quot != NULL it computes in the quotient ring modulo "quot" 1259 */ 1260 ideal idPrepare (ideal h1,ideal quot, tHomog h, 1261 int* syzcomp, int *quotgen, int *quotdim, intvec **w) 1299 *works always in a ring with ringorder_s 1300 */ 1301 static ideal idPrepare (ideal h1,ideal quot, tHomog h, 1302 int syzcomp, int *quotgen, int *quotdim, intvec **w) 1262 1303 { 1263 1304 ideal h2, h3; … … 1265 1306 int j,jj=0,k; 1266 1307 poly p,q; 1267 BOOLEAN orderChanged=FALSE;1268 1308 1269 1309 if (idIs0(h1)) return NULL; 1270 1310 k = lengthFreeModule(h1); 1271 if (*syzcomp<k) *syzcomp = k;1272 h2 = NULL;1273 1311 h2=idCopy(h1); 1274 1312 i = IDELEMS(h2)-1; 1275 //while ((i >= 0) && (h2->m[i] == NULL)) i--;1276 1313 if (k == 0) 1277 1314 { 1278 1315 for (j=0; j<=i; j++) pShift(&(h2->m[j]),1); 1279 *syzcomp = 1; 1280 } 1281 h2->rank = *syzcomp+i+1; 1316 k = 1; 1317 } 1318 if (syzcomp<k) 1319 { 1320 Warn("syzcomp too low, should be %d instead of %d",k,syzcomp); 1321 syzcomp = k; 1322 pSetSyzComp(k); 1323 } 1324 h2->rank = syzcomp+i+1; 1282 1325 for (j=0; j<=i; j++) 1283 1326 { 1284 1327 p = h2->m[j]; 1285 1328 q = pOne(); 1286 #ifdef DRING 1287 if (pDRING) { pdSetDFlag(q,1); pSetm(q); } 1288 #endif 1289 pSetComp(q,*syzcomp+1+j); 1329 pSetComp(q,syzcomp+1+j); 1290 1330 if (p!=NULL) 1291 1331 { … … 1296 1336 h2->m[j]=q; 1297 1337 } 1298 if (currRing->order[0]!=ringorder_c) 1299 { 1300 while ((currRing->order[jj]!=0) && (currRing->order[jj]!=ringorder_c) 1301 && (currRing->order[jj]!=ringorder_C)) 1302 { 1303 jj++; 1304 } 1305 if ((pOrdSgn==1) && (h==TRUE) && (*syzcomp==1) && (!pLexOrder) 1306 && (currRing->order[jj]==ringorder_c)) 1307 { 1308 for(j=0;(j<IDELEMS(h2) && (!orderChanged));j++) 1309 { 1310 if (h2->m[j] != NULL) 1311 { 1312 p=h2->m[j]; 1313 while ((p!=NULL) 1314 && (pGetComp(p)<=*syzcomp)) 1315 { 1316 if (pIsConstantComp(p)) 1317 { 1318 pSetSyzComp(*syzcomp); 1319 orderChanged=TRUE; 1320 break; 1321 } 1322 pIter(p); 1323 } 1324 } 1325 } 1326 } 1327 else 1328 { 1329 pSetSyzComp(*syzcomp); 1330 orderChanged=TRUE; 1331 } 1332 } 1333 1334 // if (orderChanged) PrintS("order changed\n"); 1335 // else PrintS("order not changed\n"); 1338 1336 1339 #ifdef PDEBUG 1337 1340 for(j=0;j<IDELEMS(h2);j++) pTest(h2->m[j]); 1338 1341 #endif 1339 h3=kStd(h2,quot,h,w,NULL,*syzcomp); 1340 //h3->rank = h2->rank; done by kStd -> initBuchMora -> initS 1341 //h3->rank-=*syzcomp; 1342 h3=kStd(h2,quot,h,w,NULL,syzcomp); 1342 1343 idDelete(&h2); 1343 if (orderChanged) pSetSyzComp(0);1344 1344 return h3; 1345 1345 } … … 1354 1354 BOOLEAN setRegularity, int °) 1355 1355 { 1356 ideal e , h3;1356 ideal e; 1357 1357 poly p; 1358 int i, j, k =0, quotdim, quotgen,length=0,reg;1358 int i, j, k, quotdim, quotgen,length=0,reg; 1359 1359 BOOLEAN isMonomial=TRUE; 1360 1360 … … 1369 1369 if (idIs0(h1)) 1370 1370 return idFreeModule(IDELEMS(h1)); 1371 h3=idPrepare(h1,quot,h,&k,"gen,"dim,w); 1372 if (h3==NULL) 1371 k=max(0,idRankFreeModule(h1)); 1372 1373 ring orig_ring=currRing; 1374 ring syz_ring=rAddSyzComp(currRing); 1375 pSetSyzComp(k); 1376 ideal s_h1=idInit(IDELEMS(h1),h1->rank); 1377 for(i=IDELEMS(h1)-1;i>=0;i--) 1378 { 1379 if(syz_ring==orig_ring) 1380 { 1381 s_h1->m[i]=pCopy(h1->m[i]); 1382 } 1383 else 1384 { 1385 s_h1->m[i]=pPermPoly(h1->m[i],NULL,orig_ring,NULL,0); 1386 } 1387 } 1388 ideal s_quot=idInit(IDELEMS(quot),1); 1389 for(i=IDELEMS(quot)-1;i>=0;i--) 1390 { 1391 if(syz_ring==orig_ring) 1392 { 1393 s_quot->m[i]=pCopy(quot->m[i]); 1394 } 1395 else 1396 { 1397 s_quot->m[i]=pPermPoly(quot->m[i],NULL,orig_ring,NULL,0); 1398 } 1399 } 1400 1401 ideal s_h3=idPrepare(s_h1,s_quot,h,k,"gen,"dim,w); 1402 idDelete(&s_h1); 1403 idDelete(&s_quot); 1404 1405 if (syz_ring!=orig_ring) 1406 rChangeCurrRing(orig_ring,TRUE); 1407 pSetSyzComp(0); 1408 1409 if (s_h3==NULL) 1410 { 1373 1411 return idFreeModule(IDELEMS(h1)); 1412 } 1374 1413 i = -1; 1375 e=idInit(16,h3->rank-k); 1376 for (j=0; j<IDELEMS(h3); j++) 1377 { 1378 if (h3->m[j] != NULL) 1379 { 1380 if (pMinComp(h3->m[j]) > k) 1381 { 1382 p = h3->m[j]; 1383 h3->m[j]=NULL; 1414 e=idInit(16,s_h3->rank-k); 1415 for (j=0; j<IDELEMS(s_h3); j++) 1416 { 1417 if (s_h3->m[j] != NULL) 1418 { 1419 if (pMinComp(s_h3->m[j],syz_ring) > k) 1420 { 1421 if (syz_ring==orig_ring) 1422 { 1423 p=s_h3->m[j]; 1424 s_h3->m[j]=NULL; 1425 } 1426 else 1427 p = pPermPoly(s_h3->m[j],NULL,syz_ring,NULL,0); 1384 1428 pShift(&p,-k); 1385 1429 if (p!=NULL) … … 1396 1440 else 1397 1441 { 1398 isMonomial=isMonomial && (pNext(h3->m[j])==NULL); 1399 pDelete(&pNext(h3->m[j])); 1400 } 1401 } 1402 } 1403 if ((!isMonomial) && (!TEST_OPT_NOTREGULARITY) && (setRegularity) && (h==isHomog)) 1404 { 1405 idSkipZeroes(h3); 1442 isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL); 1443 if(syz_ring!=orig_ring) 1444 { 1445 rChangeCurrRing(syz_ring,FALSE); 1446 pDelete(&pNext(s_h3->m[j])); 1447 rChangeCurrRing(orig_ring,TRUE); 1448 } 1449 else 1450 pDelete(&pNext(s_h3->m[j])); 1451 } 1452 } 1453 } 1454 if ((!isMonomial) 1455 && (!TEST_OPT_NOTREGULARITY) 1456 && (setRegularity) 1457 && (h==isHomog)) 1458 { 1459 idSkipZeroes(s_h3); // works ring independend 1460 ideal h3; 1461 if (syz_ring==orig_ring) 1462 h3=idCopy(s_h3); 1463 else 1464 { 1465 h3=idInit(IDELEMS(s_h3),s_h3->rank); 1466 for(i=IDELEMS(quot)-1;i>=0;i--) 1467 { 1468 h3->m[i]=pPermPoly(s_h3->m[i],NULL,syz_ring,NULL,0); 1469 } 1470 } 1406 1471 resolvente res = sySchreyerResolvente(h3,-1,&length,TRUE); 1407 1472 intvec * dummy = syBetti(res,length,®, *w); … … 1413 1478 } 1414 1479 Free((ADDRESS)res,length*sizeof(ideal)); 1415 } 1416 idDelete(&h3); 1480 idDelete(&h3); 1481 } 1482 if (syz_ring!=orig_ring) 1483 { 1484 rChangeCurrRing(syz_ring,FALSE); 1485 idDelete(&s_h3); 1486 rChangeCurrRing(orig_ring,TRUE); 1487 rKill(syz_ring); 1488 } 1489 else 1490 idDelete(&s_h3); 1417 1491 idSkipZeroes(e); 1418 1492 return e; … … 1426 1500 BOOLEAN setRegularity, int °) 1427 1501 { 1428 ideal e, h3;1429 1502 poly p; 1430 1503 intvec * reord; 1431 int i, l=0, j, k =0, quotdim, quotgen,length=0,reg;1504 int i, l=0, j, k, quotdim, quotgen,length=0,reg; 1432 1505 BOOLEAN isMonomial=TRUE; 1433 1506 1434 1507 if (idIs0(h1)) 1435 1508 return idFreeModule(1); 1436 //PrintS("h1 vorher\n");1437 //for (i=0;i<IDELEMS(h1);i++)1438 //{1439 //Print("Element %d: ",i);pWrite(h1->m[i]);1440 //}1441 1509 idSkipZeroes(h1); 1442 h3=idPrepare(h1,quot,h,&k,"gen,"dim,w); 1443 //PrintS("h1 nachher\n"); 1444 //for (i=0;i<IDELEMS(h3);i++) 1445 //{ 1446 //Print("Element %d: ",i);pWrite(h3->m[i]); 1447 //} 1448 if (h3==NULL) 1510 1511 ring orig_ring=currRing; 1512 ring syz_ring=rAddSyzComp(currRing); 1513 pSetSyzComp(k); 1514 1515 ideal s_h1=idInit(IDELEMS(h1),h1->rank); 1516 for(i=IDELEMS(h1)-1;i>=0;i--) 1517 { 1518 if(syz_ring==orig_ring) 1519 { 1520 s_h1->m[i]=pCopy(h1->m[i]); 1521 } 1522 else 1523 { 1524 s_h1->m[i]=pPermPoly(h1->m[i],NULL,orig_ring,NULL,0); 1525 } 1526 } 1527 ideal s_quot=idInit(IDELEMS(quot),1); 1528 for(i=IDELEMS(quot)-1;i>=0;i--) 1529 { 1530 if(syz_ring==orig_ring) 1531 { 1532 s_quot->m[i]=pCopy(quot->m[i]); 1533 } 1534 else 1535 { 1536 s_quot->m[i]=pPermPoly(quot->m[i],NULL,orig_ring,NULL,0); 1537 } 1538 } 1539 1540 ideal s_h3=idPrepare(s_h1,s_quot,h,k,"gen,"dim,w); 1541 for (i=IDELEMS(s_h1);i!=0;i--) 1542 pDelete(&(s_h1->m[i-1])); 1543 1544 if (s_h3==NULL) 1545 { 1546 idDelete(&s_h1); 1547 idDelete(&s_quot); 1548 if (syz_ring!=orig_ring) 1549 rChangeCurrRing(orig_ring,TRUE); 1550 pSetSyzComp(0); 1551 for (i=IDELEMS(h1);i!=0;i--) 1552 pDelete(&(h1->m[i-1])); 1449 1553 return idFreeModule(1); 1450 for (i=IDELEMS(h1);i!=0;i--)1451 pDelete(&(h1->m[i-1])); 1554 } 1555 1452 1556 reord = new intvec(IDELEMS(h1)+1); 1453 1557 i = -1; 1454 e=idInit(16,h3->rank);1455 for (j=0; j<IDELEMS( h3); j++)1456 { 1457 if ( h3->m[j] != NULL)1458 { 1459 p = h3->m[j];1558 ideal e=idInit(16,s_h3->rank); 1559 for (j=0; j<IDELEMS(s_h3); j++) 1560 { 1561 if (s_h3->m[j] != NULL) 1562 { 1563 p = s_h3->m[j]; 1460 1564 if (pGetComp(p) > k) 1461 1565 { 1462 h3->m[j]=NULL;1566 s_h3->m[j]=NULL; 1463 1567 pShift(&p,-k); 1464 1568 if (p!=NULL) … … 1475 1579 else 1476 1580 { 1477 while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) pIter(p); 1581 while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) 1582 pIter(p); 1478 1583 if (pIsConstantComp(pNext(p))) 1479 1584 { 1480 1585 (*reord)[pGetComp(pNext(p))-k] = l+1; 1481 //Print("Element %d mit Comp %d: ",j,pGetComp(pNext(p))-k); 1482 //pWrite(h3->m[j]); 1483 h1->m[l] = h3->m[j]; 1484 h3->m[j] = pCopy(h1->m[l]); 1586 s_h1->m[l] = s_h3->m[j]; 1587 s_h3->m[j] = pCopy(s_h1->m[l]); 1485 1588 pDelete(&pNext(p)); 1486 1589 l++; 1487 1590 } 1488 isMonomial=isMonomial && (pGetComp(pNext(h3->m[j]))>k); 1489 pDelete(&pNext(h3->m[j])); 1490 } 1491 } 1492 } 1493 if ((!isMonomial) && (!TEST_OPT_NOTREGULARITY) && (setRegularity) && (h==isHomog)) 1494 { 1495 idSkipZeroes(h3); 1496 resolvente res = sySchreyerResolvente(h3,0,&length); 1591 isMonomial=isMonomial && (pGetComp(pNext(s_h3->m[j]))>k); 1592 pDelete(&pNext(s_h3->m[j])); 1593 } 1594 } 1595 } 1596 if ((!isMonomial) 1597 && (!TEST_OPT_NOTREGULARITY) 1598 && (setRegularity) 1599 && (h==isHomog)) 1600 { 1601 idSkipZeroes(s_h3); 1602 resolvente res; 1603 if (syz_ring==orig_ring) 1604 res = sySchreyerResolvente(s_h3,0,&length); 1605 else 1606 { 1607 rChangeCurrRing(orig_ring,TRUE); 1608 ideal h3=idInit(IDELEMS(s_h3),s_h3->rank); 1609 for(j=IDELEMS(s_h3)-1;j>=0;j--) 1610 { 1611 h3->m[j]=pPermPoly(s_h3->m[j],NULL,syz_ring,NULL,0); 1612 } 1613 res = sySchreyerResolvente(h3,0,&length); 1614 idDelete(&h3); 1615 rChangeCurrRing(syz_ring,FALSE); 1616 idDelete(&s_h3); 1617 rChangeCurrRing(orig_ring,TRUE); 1618 } 1497 1619 intvec * dummy = syBetti(res,length,®, *w); 1498 1620 deg = reg+2; … … 1503 1625 } 1504 1626 Free((ADDRESS)res,length*sizeof(ideal)); 1505 } 1506 idDelete(&h3); 1507 //PrintS("Komponententransformation: "); 1508 //reord->show(); 1509 //PrintLn(); 1510 for (i=IDELEMS(e);i!=0;i--) 1511 { 1512 if (e->m[i-1]!=NULL) 1513 { 1514 p = e->m[i-1]; 1627 if(syz_ring!=orig_ring) 1628 rChangeCurrRing(syz_ring,TRUE); 1629 } 1630 else 1631 { 1632 idDelete(&s_h3); 1633 } 1634 ideal ee; 1635 if(syz_ring!=orig_ring) 1636 { 1637 rChangeCurrRing(orig_ring,TRUE); 1638 ee=idInit(IDELEMS(e),e->rank); 1639 for(j=IDELEMS(e)-1;j>=0;j--) 1640 { 1641 ee->m[j]=pPermPoly(e->m[j],NULL,syz_ring,NULL,0); 1642 } 1643 rChangeCurrRing(syz_ring,FALSE); 1644 idDelete(&e); 1645 rChangeCurrRing(orig_ring,TRUE); 1646 } 1647 else 1648 { 1649 ee=e; 1650 e=NULL; 1651 } 1652 1653 for (i=IDELEMS(ee);i!=0;i--) 1654 { 1655 if (ee->m[i-1]!=NULL) 1656 { 1657 p = ee->m[i-1]; 1515 1658 while (p!=NULL) 1516 1659 { … … 1519 1662 pIter(p); 1520 1663 } 1521 e ->m[i-1] = pOrdPolyMerge(e->m[i-1]);1522 } 1523 } 1524 idSkipZeroes(e );1664 ee->m[i-1] = pOrdPolyMerge(ee->m[i-1]); 1665 } 1666 } 1667 idSkipZeroes(ee); 1525 1668 delete reord; 1526 return e; 1669 1670 return ee; 1527 1671 } 1528 1672 … … 1533 1677 ideal idLiftStd (ideal h1,ideal quot, matrix* ma, tHomog h) 1534 1678 { 1535 int i, j, k =0, t, quotgen, inputIsIdeal=lengthFreeModule(h1);1679 int i, j, k, t, quotgen, inputIsIdeal=lengthFreeModule(h1); 1536 1680 ideal e, h3; 1537 1681 poly p=NULL, q, qq; … … 1542 1686 if (idIs0(h1)) 1543 1687 return idInit(1,h1->rank); 1688 k=max(0,idRankFreeModule(h1)); 1689 //RING AENDERN(pSetSyzComp(k)) 1544 1690 h3=idPrepare(h1,quot,h,&k,"gen,&i,&w); 1691 //RING AENDERN(pSetSyzComp) 1545 1692 if (w!=NULL) delete w; 1546 1693 i = 0; … … 1579 1726 } 1580 1727 if (!inputIsIdeal) pShift(&qq,-1); 1581 //if (quotgen != 0) 1582 //{ 1583 // q = kNF(quot,qq); 1584 // pDelete(&qq); 1585 //} 1586 //else 1587 q = qq; 1728 q = qq; 1588 1729 if (q !=NULL) 1589 1730 { … … 1617 1758 if ((idRankFreeModule(mod)!=0) && (lsmod==0)) lsmod=1; 1618 1759 k=lsmod; 1619 //idSkipZeroes(mod); 1620 h3=idPrepare(mod,currQuotient,(tHomog)FALSE,&k,"gen,&i,NULL); 1760 //RING AENDERN(pSetSyzComp(k)) 1761 h3=idPrepare(mod,currQuotient,(tHomog)FALSE,k,"gen,&i,NULL); 1762 //RING AENDERN(pSetSyzComp) 1763 pSetSyzComp(k); 1621 1764 if (!goodShape) 1622 1765 { … … 1641 1784 temp = submod; 1642 1785 } 1643 pSetSyzComp(k);1644 1786 result = kNF(h3,currQuotient,temp,k); 1645 1787 result->rank = h3->rank; -
Singular/polys.cc
r9a384e re960943 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.4 4 1999-10-01 16:24:39 obachmanExp $ */4 /* $Id: polys.cc,v 1.45 1999-10-14 12:50:26 Singular Exp $ */ 5 5 6 6 /* … … 138 138 break; 139 139 } 140 case ro_syz: 141 { 142 int c=pGetComp(p); 143 p->exp.l[o->data.syz.place]= (o->data.syz.limit > c); 144 break; 145 } 140 146 default: 141 147 Print("wrong ord in rSetm:%d\n",o->ord_typ); … … 387 393 } 388 394 389 /*2390 *the pComp0 for normal syzygies391 *compares monomials in the usual ring order (pCompOld)392 *but groups module indecees according indexBounds befor393 */394 static int mcompSyz(poly p1,poly p2)395 {396 if (pGetComp(p1)<=pMaxBound)397 {398 if (pGetComp(p2)>pMaxBound) return 1;399 }400 else if (pGetComp(p2)<=pMaxBound)401 {402 return -1;403 }404 return pCompOld(p1,p2);405 }406 407 395 void pSetSyzComp(int k) 408 396 { 409 if (k!=0) 410 { 411 if (pMaxBound==0) 412 { 413 pCompOld = pComp0; 414 pComp0 = mcompSyz; 415 } 416 pMaxBound = k; 417 } 418 else 419 { 420 if (pMaxBound!=0) 421 { 422 pComp0 = pCompOld; 423 pMaxBound = 0; 424 } 397 pMaxBound=k; 398 if(currRing->typ[0].ord_typ==ro_syz) 399 { 400 currRing->typ[0].data.syz.limit=k; 401 } 402 else if (k!=0) 403 { 404 Warn("syzcomp in incompatible ring"); 425 405 } 426 406 } -
Singular/polys.h
r9a384e re960943 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1.2 4 1999-09-29 10:59:37 obachmanExp $ */6 /* $Id: polys.h,v 1.25 1999-10-14 12:50:27 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials … … 245 245 int pLength(poly a); 246 246 int pMaxComp(poly p); 247 int pMinComp(poly p );247 int pMinComp(poly p, ring r=currRing); 248 248 BOOLEAN pOneComp(poly p); 249 249 int pWeight(int c); -
Singular/polys1.cc
r9a384e re960943 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys1.cc,v 1. 29 1999-09-29 10:59:38 obachmanExp $ */4 /* $Id: polys1.cc,v 1.30 1999-10-14 12:50:27 Singular Exp $ */ 5 5 6 6 /* … … 646 646 * returns minimal column number in the modul element a (or 0) 647 647 */ 648 int pMinComp(poly p )648 int pMinComp(poly p, ring r) 649 649 { 650 650 int result,i; 651 651 652 652 if(p==NULL) return 0; 653 result = p GetComp(p);653 result = pRingGetComp(r,p); 654 654 while (pNext(p)!=NULL) 655 655 { 656 656 pIter(p); 657 i = p GetComp(p);657 i = pRingGetComp(r,p); 658 658 if (i<result) result = i; 659 659 } -
Singular/ring.cc
r9a384e re960943 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.6 8 1999-09-29 17:20:14Singular Exp $ */4 /* $Id: ring.cc,v 1.69 1999-10-14 12:50:28 Singular Exp $ */ 5 5 6 6 /* … … 27 27 #include "ring.h" 28 28 29 // static procedures 29 static const char * const ringorder_name[] = 30 { 31 " ?", //ringorder_no = 0, 32 "a", //ringorder_a, 33 "c", //ringorder_c, 34 "C", //ringorder_C, 35 "M", //ringorder_M, 36 "S", //ringorder_S, 37 "s", //ringorder_s, 38 "lp", //ringorder_lp, 39 "dp", //ringorder_dp, 40 "Dp", //ringorder_Dp, 41 "wp", //ringorder_wp, 42 "Wp", //ringorder_Wp, 43 "ls", //ringorder_ls, 44 "ds", //ringorder_ds, 45 "Ds", //ringorder_Ds, 46 "ws", //ringorder_ws, 47 "Ws", //ringorder_Ws, 48 #ifdef HAVE_SHIFTED_EXPONENTS 49 "L", //ringorder_L, 50 #endif 51 " _" //ringorder_unspec 52 }; 53 54 static inline const char * rSimpleOrdStr(int ord) 55 { 56 return ringorder_name[ord]; 57 } 58 30 59 // unconditionally deletes fields in r 31 60 static void rDelete(ring r); … … 262 291 intvec *iv = (intvec *)(sl->data); 263 292 if (((*iv)[1]==ringorder_c)||((*iv)[1]==ringorder_C)) i++; 293 #ifdef HAVE_SHIFTED_EXPONENTS 294 else if ((*iv)[1]==ringorder_L) 295 { 296 R->bitmask=(*iv)[2]; 297 n--; 298 } 299 #endif 264 300 else if ((*iv)[1]!=ringorder_a) o++; 265 #ifdef HAVE_SHIFTED_EXPONENTS266 else if ((*iv)[1]!=ringorder_L)267 {268 R->bitmask=(*iv)[2];269 }270 else271 #endif272 301 n++; 273 302 sl=sl->next; … … 729 758 Print("\n// block %3d : ",l+1); 730 759 731 Print("ordering %c", (" acCMSldDwWldDwWu")[r->order[l]]); 732 if (r->order[l]>=ringorder_lp) 733 { 734 if (r->order[l]>=ringorder_ls) 735 PrintS("s"); 736 else 737 PrintS("p"); 738 } 760 Print("ordering %s", rSimpleOrdStr(r->order[l])); 739 761 740 762 if ((r->order[l] >= ringorder_lp) … … 1046 1068 int rOrderName(char * ordername) 1047 1069 { 1048 int order=0; 1049 1050 switch (*ordername) 1051 { 1052 case 'l': 1053 if (*(ordername+1)=='p') order = ringorder_lp; 1054 else if (*(ordername+1)=='s') order = ringorder_ls; 1055 break; 1056 case 'd': 1057 if (*(ordername+1)=='p') order = ringorder_dp; 1058 else if (*(ordername+1)=='s') order = ringorder_ds; 1059 break; 1060 case 'w': 1061 if (*(ordername+1)=='p') order = ringorder_wp; 1062 else if (*(ordername+1)=='s') order = ringorder_ws; 1063 break; 1064 case 'D': 1065 if (*(ordername+1)=='p') order = ringorder_Dp; 1066 else if (*(ordername+1)=='s') order = ringorder_Ds; 1067 break; 1068 case 'W': 1069 if (*(ordername+1)=='p') order = ringorder_Wp; 1070 else if (*(ordername+1)=='s') order = ringorder_Ws; 1071 break; 1072 case 'c': order = ringorder_c; break; 1073 case 'C': order = ringorder_C; break; 1074 case 'a': order = ringorder_a; break; 1075 case 'S': order = ringorder_S; break; 1076 case 'M': order = ringorder_M; break; 1077 #ifdef HAVE_SHIFTED_EXPONENTS 1078 case 'L': order = ringorder_L; break; 1079 #endif 1080 default: break; 1070 int order=ringorder_unspec; 1071 while (order!= 0) 1072 { 1073 if (strcmp(ordername,rSimpleOrdStr(order))==0) 1074 break; 1075 order--; 1081 1076 } 1082 1077 if (order==0) Werror("wrong ring order `%s`",ordername); … … 1095 1090 for (l=0; ; l++) 1096 1091 { 1097 StringAppend("%c",(" acCMSldDwWldDwW")[r->order[l]]); 1098 if (r->order[l]>=ringorder_lp) 1099 { 1100 if (r->order[l]>=ringorder_ls) 1101 StringAppendS("s"); 1102 else 1103 StringAppendS("p"); 1104 } 1092 StringAppend((char *)rSimpleOrdStr(r->order[l])); 1105 1093 if ((r->order[l] != ringorder_c) && (r->order[l] != ringorder_C)) 1106 1094 { … … 2020 2008 } 2021 2009 } 2022 if ((r->VarOffset[i]<0) ||(r->VarOffset[i]>r->ExpESize-1)) 2023 { 2024 Print("varoffset out of range for var %d: %d\n",i,r->VarOffset[i]); 2010 int tmp; 2011 #ifdef HAVE_SHIFTED_EXPONENTS 2012 tmp=r->VarOffset[i] & 0xffffff; 2013 #if SIZEOF_LONG == 8 2014 if ((r->VarOffset[i] >> 24) >63) 2015 #else 2016 if ((r->VarOffset[i] >> 24) >31) 2017 #endif 2018 Print("bit_start out of range:%d\n",r->VarOffset[i] >> 24); 2019 #else 2020 tmp=r->VarOffset[i]; 2021 #endif 2022 if ((tmp<0) ||(tmp>r->ExpESize-1)) 2023 { 2024 Print("varoffset out of range for var %d: %d\n",i,tmp); 2025 2025 } 2026 2026 } … … 2047 2047 2048 2048 #ifdef HAVE_SHIFTED_EXPONENTS 2049 static void rO_Align(int &place , int &bit_place)2049 static void rO_Align(int &place) 2050 2050 { 2051 2051 // increment place to the next aligned one 2052 2052 // (count as Exponent_t,align as longs) 2053 if (place & ((sizeof(long)/sizeof(Exponent_t))-1)) 2054 { 2055 place += ((sizeof(long)/sizeof(Exponent_t))-1); 2056 place &= (~((sizeof(long)/sizeof(Exponent_t))-1)); 2057 } 2058 bit_place=0; 2059 } 2060 #else 2061 static void rO_Align(int &place) 2062 { 2063 // increment place to the next aligned one 2064 // (count as Exponent_t,align as longs) 2065 if (place & ((sizeof(long)/sizeof(Exponent_t))-1)) 2066 { 2067 place += ((sizeof(long)/sizeof(Exponent_t))-1); 2068 place &= (~((sizeof(long)/sizeof(Exponent_t))-1)); 2069 } 2070 } 2071 #endif 2053 if (place & ((sizeof(long)*8)-1)) 2054 { 2055 place += ((sizeof(long)*8)-1); 2056 place &= (~((sizeof(long)*8)-1)); 2057 } 2058 } 2072 2059 2073 2060 static void rO_TDegree(int &place, int start, int end, 2074 long *o, sro_ord &ord_struct )2061 long *o, sro_ord &ord_struct, int bits) 2075 2062 { 2076 2063 // degree (aligned) of variables v_start..v_end, ordsgn 1 … … 2079 2066 ord_struct.data.dp.start=start; 2080 2067 ord_struct.data.dp.end=end; 2081 ord_struct.data.dp.place=place/(sizeof(long) /sizeof(Exponent_t));2068 ord_struct.data.dp.place=place/(sizeof(long)*8)); 2082 2069 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2083 2070 place++; … … 2093 2080 ord_struct.data.dp.start=start; 2094 2081 ord_struct.data.dp.end=end; 2095 ord_struct.data.dp.place=place/(sizeof(long) /sizeof(Exponent_t));2082 ord_struct.data.dp.place=place/(sizeof(long)*8); 2096 2083 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2097 2084 place++; … … 2107 2094 ord_struct.data.wp.start=start; 2108 2095 ord_struct.data.wp.end=end; 2109 ord_struct.data.wp.place=place/(sizeof(long) /sizeof(Exponent_t));2096 ord_struct.data.wp.place=place/(sizeof(long)*8); 2110 2097 ord_struct.data.wp.weights=weights; 2111 2098 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; … … 2122 2109 ord_struct.data.wp.start=start; 2123 2110 ord_struct.data.wp.end=end; 2124 ord_struct.data.wp.place=place/(sizeof(long) /sizeof(Exponent_t));2111 ord_struct.data.wp.place=place/(sizeof(long)*8); 2125 2112 ord_struct.data.wp.weights=weights; 2126 2113 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; … … 2129 2116 } 2130 2117 2131 #ifdef HAVE_SHIFTED_EXPONENTS 2132 static void rO_LexVars(int &place, int start, int end, int &prev_ord, 2133 long *o,int *v, int bits) 2118 static void rO_LexVars(int &place, int start, int end, 2119 int &prev_ord, long *o,int *v, int bits) 2134 2120 { 2135 2121 // a block of variables v_start..v_end with lex order, ordsgn 1 2136 2122 int k; 2137 2123 int incr=1; 2138 if(prev_ord==-1) rO_Align(place); 2124 if(prev_ord!=1) rO_Align(place); 2125 int e_place=place/ sizeof(Exponent_t); 2126 int bit_place=place - (e_place*sizeof(Exponent_t)); 2139 2127 if (start>end) 2140 2128 { 2141 2129 incr=-1; 2142 2130 } 2143 int bit_start=0;2144 2131 for(k=start;;k+=incr) 2145 2132 { 2146 o[place/(sizeof( long)/sizeof(Exponent_t))]=1;2147 v[k]= place | (bit_start<< 24);2148 bit_ start+=bits;2133 o[place/(sizeof(Exponent_t)*8)]=1; 2134 v[k]=e_place | (bit_place << 24); 2135 bit_place+=bits; 2149 2136 #if SIZEOF_LONG == 4 2150 if (bit_ start > 32-bits) { bit_start=0;place++; }2137 if (bit_place > 32-bits) { bit_place=0; e_place++; } 2151 2138 #else /* SIZEOF_LONG == 8 */ 2152 if (bit_ start > 64-bits) { bit_start=0;place++; }2139 if (bit_place > 64-bits) { bit_place=0; e_place++; } 2153 2140 #endif 2154 2141 if (k==end) break; 2155 2142 } 2156 2143 prev_ord=1; 2157 } 2158 2159 static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord, 2160 long *o,int *v, int bits) 2144 place = e_place*sizeof(Exponent_t)+bit_place; 2145 } 2146 2147 static void rO_LexVars_neg(int &place, int start, int end, 2148 int &prev_ord, long *o,int *v, int bits) 2161 2149 { 2162 2150 // a block of variables v_start..v_end with lex order, ordsgn -1 2163 2151 int k; 2164 2152 int incr=1; 2165 if(prev_ord==1) rO_Align(place); 2153 if(prev_ord!=-1) rO_Align(place); 2154 int e_place=place/ sizeof(Exponent_t); 2155 int bit_place=place - (e_place*sizeof(Exponent_t)); 2166 2156 if (start>end) 2167 2157 { 2168 2158 incr=-1; 2169 2159 } 2170 int bit_start=0;2171 2160 for(k=start;;k+=incr) 2172 2161 { 2173 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2174 v[k]=place | (bit_start << 24); 2162 o[place/(sizeof(Exponent_t)*8)]=-1; 2163 v[k]=e_place | (bit_place << 24); 2164 bit_place+=bits; 2175 2165 #if SIZEOF_LONG == 4 2176 if (bit_ start > 32-bits) { bit_start=0;place++; }2166 if (bit_place > 32-bits) { bit_place=0; e_place++; } 2177 2167 #else /* SIZEOF_LONG == 8 */ 2178 if (bit_ start > 64-bits) { bit_start=0;place++; }2168 if (bit_place > 64-bits) { bit_place=0; e_place++; } 2179 2169 #endif 2180 2170 if (k==end) break; 2181 2171 } 2182 2172 prev_ord=-1; 2183 } 2184 2185 #else 2186 2187 static void rO_LexVars(int &place, int start, int end, int &prev_ord, 2188 long *o,int *v) 2189 { 2190 // a block of variables v_start..v_end with lex order, ordsgn 1 2191 int k; 2192 int incr=1; 2193 if(prev_ord==-1) rO_Align(place); 2194 if (start>end) 2195 { 2196 incr=-1; 2197 } 2198 for(k=start;;k+=incr) 2199 { 2200 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2201 v[k]=place; 2202 place++; 2203 if (k==end) break; 2204 } 2205 prev_ord=1; 2206 } 2207 2208 static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord, 2209 long *o,int *v) 2210 { 2211 // a block of variables v_start..v_end with lex order, ordsgn -1 2212 int k; 2213 int incr=1; 2214 if(prev_ord==1) rO_Align(place); 2215 if (start>end) 2216 { 2217 incr=-1; 2218 } 2219 for(k=start;;k+=incr) 2220 { 2221 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2222 v[k]=place; 2223 place++; 2224 if (k==end) break; 2225 } 2226 prev_ord=-1; 2227 } 2228 2229 #endif 2230 2231 #ifndef HAVE_SHIFTED_EXPONENTS 2232 #ifdef LONG_MONOMS 2233 static void rO_DupVars(int &place, int start, int end) 2234 { 2235 // a block of variables v_start..v_end to be duplicated (for pDivisibleBy): 2236 place+=(end-start+1); 2237 } 2238 #endif 2239 #endif 2173 place = e_place*sizeof(Exponent_t)+bit_place; 2174 } 2240 2175 2241 2176 static void rO_Syzcomp(int &place, int &prev_ord, … … 2245 2180 rO_Align(place); 2246 2181 ord_struct.ord_typ=ro_syzcomp; 2247 ord_struct.data.syzcomp.place=place/(sizeof(long) /sizeof(Exponent_t));2182 ord_struct.data.syzcomp.place=place/(sizeof(long)*8)); 2248 2183 ord_struct.data.syzcomp.Components=NULL; 2249 2184 ord_struct.data.syzcomp.ShiftedComponents=NULL; 2250 o[place/(sizeof(long) /sizeof(Exponent_t))]=1;2185 o[place/(sizeof(long)*8)]=1; 2251 2186 prev_ord=1; 2252 2187 place++; 2253 rO_Align(place); 2254 } 2255 2256 #ifdef HAVE_SHIFTED_EXPONENTS 2188 rO_Align(place,bit_place); 2189 } 2190 2191 static void rO_Syz(int &place, int &prev_ord, 2192 long *o, sro_ord &ord_struct) 2193 { 2194 // ordering is derived from component number 2195 if (prev_ord!= -1) rO_Align(place); 2196 if ((place & 7) ERROR; 2197 ord_struct.ord_typ=ro_syz; 2198 ord_struct.data.syz.place=place/(sizeof(Exponent_t)*8)); 2199 ord_struct.data.syz.limit=0; 2200 o[place/(sizeof(Exponent_t)*8)]= -1; 2201 prev_ord=-1; 2202 place+=Exponent_t*8; 2203 } 2204 2257 2205 BOOLEAN rComplete(ring r, int force) 2258 2206 { … … 2261 2209 int n=rBlocks(r)-1; 2262 2210 int i; 2263 int j=0;2264 int prev_ordsgn=0;2265 long *tmp_ordsgn=(long *)Alloc0(2*(n+r->N)*sizeof(long)); // wil be used for ordsgn2266 int *v=(int *)Alloc((r->N+1)*sizeof(int)); // will be used for VarOffset2267 for(i=r->N; i>=0 ; i--)2268 {2269 v[i]=-1;2270 }2271 sro_ord *tmp_typ=(sro_ord *)Alloc0(2*(n+r->N)*sizeof(sro_ord));2272 int typ_i=0;2273 2211 int bits; 2274 int bit_place=0;2275 2212 switch(r->bitmask) 2276 2213 { 2214 case 0: 2277 2215 #if SIZEOF_LONG == 8 2216 r->bitmask=0xffffffffffffffffL; /* NO break */ 2278 2217 case 0xffffffffffffffffL: bits=64; break; /* 64 bit longs only */ 2279 2218 #endif 2219 r->bitmask=0xffffffff; /* NO break */ 2280 2220 case 0xffffffff: bits=32; break; 2281 2221 #if SIZEOF_LONG == 8 … … 2303 2243 return TRUE; 2304 2244 } 2245 long *tmp_ordsgn=(long *)Alloc0(2*(n+r->N)*sizeof(long)); // wil be used for ordsgn 2246 int *v=(int *)Alloc((r->N+1)*sizeof(int)); // will be used for VarOffset 2247 for(i=r->N; i>=0 ; i--) 2248 { 2249 v[i]=-1; 2250 } 2251 sro_ord *tmp_typ=(sro_ord *)Alloc0(2*(n+r->N)*sizeof(sro_ord)); 2252 int typ_i=0; 2253 int bit_place=0; 2254 int prev_ordsgn=0; 2305 2255 r->pVarLowIndex=0; 2306 2256 2307 2257 // fill in v, tmp_typ, tmp_ordsgn, determine pVarLowIndex, typ_i (== ordSize) 2258 int j=0; 2259 int j_bits=0; 2308 2260 for(i=0;i<n;i++) 2309 2261 { … … 2311 2263 { 2312 2264 case ringorder_a: 2313 rO_WDegree(j, r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],2265 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i], 2314 2266 r->wvhdl[i]); 2315 2267 r->pVarLowIndex=j; … … 2318 2270 2319 2271 case ringorder_c: 2320 rO_LexVars_neg(j, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);2272 rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,bits); 2321 2273 break; 2322 2274 2323 2275 case ringorder_C: 2324 rO_LexVars(j, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);2276 rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,bits); 2325 2277 break; 2326 2278 … … 2331 2283 for(l=0;l<k;l++) 2332 2284 { 2333 rO_WDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i], 2285 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2286 tmp_typ[typ_i], 2334 2287 r->wvhdl[i]+(r->block1[i]-r->block0[i]+1)*l); 2335 2288 typ_i++; … … 2340 2293 2341 2294 case ringorder_lp: 2342 rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,2343 bits);2295 rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn, 2296 tmp_ordsgn,v,bits); 2344 2297 break; 2345 2298 2346 2299 case ringorder_ls: 2347 rO_LexVars_neg(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,2348 bits);2300 rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn, 2301 tmp_ordsgn,v, bits); 2349 2302 break; 2350 2303 … … 2352 2305 if (r->block0[i]==r->block1[i]) 2353 2306 { 2354 rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,2355 bits);2307 rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn, 2308 tmp_ordsgn,v, bits); 2356 2309 } 2357 2310 else 2358 2311 { 2359 rO_TDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]); 2312 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2313 tmp_typ[typ_i]); 2360 2314 r->pVarLowIndex=j; 2361 2315 typ_i++; 2362 rO_LexVars_neg(j, r->block1[i],r->block0[i]+1,2316 rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1, 2363 2317 prev_ordsgn,tmp_ordsgn,v,bits); 2364 2318 } … … 2368 2322 if (r->block0[i]==r->block1[i]) 2369 2323 { 2370 rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,2371 bits);2324 rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn, 2325 tmp_ordsgn,v, bits); 2372 2326 } 2373 2327 else 2374 2328 { 2375 rO_TDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]); 2329 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2330 tmp_typ[typ_i]); 2376 2331 r->pVarLowIndex=j; 2377 2332 typ_i++; 2378 rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,2379 bits);2333 rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn, 2334 tmp_ordsgn,v, bits); 2380 2335 } 2381 2336 break; … … 2384 2339 if (r->block0[i]==r->block1[i]) 2385 2340 { 2386 rO_LexVars_neg(j, r->block0[i],r->block1[i],prev_ordsgn,tmp_ordsgn,v,2387 bits);2341 rO_LexVars_neg(j, j_bits,r->block0[i],r->block1[i],prev_ordsgn, 2342 tmp_ordsgn,v,bits); 2388 2343 } 2389 2344 else 2390 2345 { 2391 rO_TDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]); 2346 rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2347 tmp_typ[typ_i]); 2392 2348 r->pVarLowIndex=j; 2393 2349 typ_i++; 2394 rO_LexVars_neg(j, r->block1[i],r->block0[i]+1,2350 rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1, 2395 2351 prev_ordsgn,tmp_ordsgn,v,bits); 2396 2352 } … … 2400 2356 if (r->block0[i]==r->block1[i]) 2401 2357 { 2402 rO_LexVars_neg(j, r->block0[i],r->block1[i],prev_ordsgn,tmp_ordsgn,v,2403 bits);2358 rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i],prev_ordsgn, 2359 tmp_ordsgn,v, bits); 2404 2360 } 2405 2361 else 2406 2362 { 2407 rO_TDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]); 2363 rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2364 tmp_typ[typ_i]); 2408 2365 r->pVarLowIndex=j; 2409 2366 typ_i++; 2410 rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,2411 bits);2367 rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn, 2368 tmp_ordsgn,v, bits); 2412 2369 } 2413 2370 break; 2414 2371 2415 2372 case ringorder_wp: 2416 rO_WDegree(j, r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],2417 r->wvhdl[i]);2373 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2374 tmp_typ[typ_i], r->wvhdl[i]); 2418 2375 r->pVarLowIndex=j; 2419 2376 typ_i++; 2420 2377 if (r->block1[i]!=r->block0[i]) 2421 rO_LexVars_neg(j, r->block1[i],r->block0[i]+1, prev_ordsgn,tmp_ordsgn,2422 v,bits);2378 rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn, 2379 tmp_ordsgn, v,bits); 2423 2380 break; 2424 2381 2425 2382 case ringorder_Wp: 2426 rO_WDegree(j, r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],2427 r->wvhdl[i]);2383 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2384 tmp_typ[typ_i], r->wvhdl[i]); 2428 2385 r->pVarLowIndex=j; 2429 2386 typ_i++; 2430 2387 if (r->block1[i]!=r->block0[i]) 2431 rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,2432 bits);2388 rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn, 2389 tmp_ordsgn,v, bits); 2433 2390 break; 2434 2391 2435 2392 case ringorder_ws: 2436 rO_WDegree_neg(j, r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],2437 r->wvhdl[i]);2393 rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2394 tmp_typ[typ_i], r->wvhdl[i]); 2438 2395 r->pVarLowIndex=j; 2439 2396 typ_i++; 2440 2397 if (r->block1[i]!=r->block0[i]) 2441 rO_LexVars_neg(j, r->block1[i],r->block0[i]+1, prev_ordsgn,tmp_ordsgn,2442 v,bits);2398 rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn, 2399 tmp_ordsgn, v,bits); 2443 2400 break; 2444 2401 2445 2402 case ringorder_Ws: 2446 rO_WDegree_neg(j, r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],2447 r->wvhdl[i]);2403 rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn, 2404 tmp_typ[typ_i], r->wvhdl[i]); 2448 2405 r->pVarLowIndex=j; 2449 2406 typ_i++; 2450 2407 if (r->block1[i]!=r->block0[i]) 2451 rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,2452 bits);2408 rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn, 2409 tmp_ordsgn,v, bits); 2453 2410 break; 2454 2411 2455 2412 case ringorder_S: 2456 rO_Syzcomp(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 2413 rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 2414 r->pVarLowIndex=j; 2415 typ_i++; 2416 break; 2417 2418 case ringorder_s: 2419 rO_Syz(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 2457 2420 r->pVarLowIndex=j; 2458 2421 typ_i++; … … 2468 2431 2469 2432 int j0=j-1; 2470 rO_Align(j );2433 rO_Align(j,j_bits); 2471 2434 r->pCompHighIndex=(j-1)/(sizeof(long)/sizeof(Exponent_t)); 2472 2435 j=j0+1; … … 2479 2442 if (prev_ordsgn==1) 2480 2443 { 2481 rO_LexVars(j, i,i, prev_ordsgn,tmp_ordsgn,v,bits);2444 rO_LexVars(j, j_bits, i,i, prev_ordsgn,tmp_ordsgn,v,bits); 2482 2445 } 2483 2446 else 2484 2447 { 2485 rO_LexVars_neg(j, 2448 rO_LexVars_neg(j,j_bits,i,i, prev_ordsgn,tmp_ordsgn,v,bits); 2486 2449 } 2487 2450 } … … 2489 2452 2490 2453 r->pVarHighIndex=j-1; 2491 rO_Align(j );2454 rO_Align(j,j_bits); 2492 2455 // ---------------------------- 2493 2456 // finished with constructing the monomial, computing sizes: … … 2563 2526 for(j=r->N;j>=0;j--) 2564 2527 { 2565 r->VarOffset[j]=r->ExpESize-v[j]-1; 2528 int tmp=v[j]; 2529 r->VarOffset[j] = r->ExpESize-(tmp & 0xffffff)-1; 2530 r->VarOffset[j] |= (tmp & (~0xffffff)); 2566 2531 } 2567 2532 Free((ADDRESS)v,(r->N+1)*sizeof(int)); … … 2586 2551 return FALSE; 2587 2552 } 2588 #else 2553 #else /* not HAVE_SHIFTED_EXPONENTS: */ 2554 static void rO_Align(int &place) 2555 { 2556 // increment place to the next aligned one 2557 // (count as Exponent_t,align as longs) 2558 if (place & ((sizeof(long)/sizeof(Exponent_t))-1)) 2559 { 2560 place += ((sizeof(long)/sizeof(Exponent_t))-1); 2561 place &= (~((sizeof(long)/sizeof(Exponent_t))-1)); 2562 } 2563 } 2564 2565 static void rO_TDegree(int &place, int start, int end, 2566 long *o, sro_ord &ord_struct) 2567 { 2568 // degree (aligned) of variables v_start..v_end, ordsgn 1 2569 rO_Align(place); 2570 ord_struct.ord_typ=ro_dp; 2571 ord_struct.data.dp.start=start; 2572 ord_struct.data.dp.end=end; 2573 ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t)); 2574 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2575 place++; 2576 rO_Align(place); 2577 } 2578 2579 static void rO_TDegree_neg(int &place, int start, int end, 2580 long *o, sro_ord &ord_struct) 2581 { 2582 // degree (aligned) of variables v_start..v_end, ordsgn -1 2583 rO_Align(place); 2584 ord_struct.ord_typ=ro_dp; 2585 ord_struct.data.dp.start=start; 2586 ord_struct.data.dp.end=end; 2587 ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t)); 2588 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2589 place++; 2590 rO_Align(place); 2591 } 2592 2593 static void rO_WDegree(int &place, int start, int end, 2594 long *o, sro_ord &ord_struct, int *weights) 2595 { 2596 // weighted degree (aligned) of variables v_start..v_end, ordsgn 1 2597 rO_Align(place); 2598 ord_struct.ord_typ=ro_wp; 2599 ord_struct.data.wp.start=start; 2600 ord_struct.data.wp.end=end; 2601 ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t)); 2602 ord_struct.data.wp.weights=weights; 2603 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2604 place++; 2605 rO_Align(place); 2606 } 2607 2608 static void rO_WDegree_neg(int &place, int start, int end, 2609 long *o, sro_ord &ord_struct, int *weights) 2610 { 2611 // weighted degree (aligned) of variables v_start..v_end, ordsgn -1 2612 rO_Align(place); 2613 ord_struct.ord_typ=ro_wp; 2614 ord_struct.data.wp.start=start; 2615 ord_struct.data.wp.end=end; 2616 ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t)); 2617 ord_struct.data.wp.weights=weights; 2618 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2619 place++; 2620 rO_Align(place); 2621 } 2622 2623 static void rO_LexVars(int &place, int start, int end, int &prev_ord, 2624 long *o,int *v) 2625 { 2626 // a block of variables v_start..v_end with lex order, ordsgn 1 2627 int k; 2628 int incr=1; 2629 if(prev_ord!=1) rO_Align(place); 2630 if (start>end) 2631 { 2632 incr=-1; 2633 } 2634 for(k=start;;k+=incr) 2635 { 2636 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2637 v[k]=place; 2638 place++; 2639 if (k==end) break; 2640 } 2641 prev_ord=1; 2642 } 2643 2644 static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord, 2645 long *o,int *v) 2646 { 2647 // a block of variables v_start..v_end with lex order, ordsgn -1 2648 int k; 2649 int incr=1; 2650 if(prev_ord!=-1) rO_Align(place); 2651 if (start>end) 2652 { 2653 incr=-1; 2654 } 2655 for(k=start;;k+=incr) 2656 { 2657 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2658 v[k]=place; 2659 place++; 2660 if (k==end) break; 2661 } 2662 prev_ord=-1; 2663 } 2664 2665 #ifdef LONG_MONOMS 2666 static void rO_DupVars(int &place, int start, int end) 2667 { 2668 // a block of variables v_start..v_end to be duplicated (for pDivisibleBy): 2669 place+=(end-start+1); 2670 } 2671 #endif 2672 2673 static void rO_Syzcomp(int &place, int &prev_ord, 2674 long *o, sro_ord &ord_struct) 2675 { 2676 // ordering is derived from component number 2677 rO_Align(place); 2678 ord_struct.ord_typ=ro_syzcomp; 2679 ord_struct.data.syzcomp.place=place/(sizeof(long)/sizeof(Exponent_t)); 2680 ord_struct.data.syzcomp.Components=NULL; 2681 ord_struct.data.syzcomp.ShiftedComponents=NULL; 2682 o[place/(sizeof(long)/sizeof(Exponent_t))]=1; 2683 prev_ord=1; 2684 place++; 2685 rO_Align(place); 2686 } 2687 2688 static void rO_Syz(int &place, int &prev_ord, 2689 long *o, sro_ord &ord_struct) 2690 { 2691 // ordering is derived from component number 2692 if(prev_ord!= -1) rO_Align(place); 2693 ord_struct.ord_typ=ro_syz; 2694 ord_struct.data.syz.place=place/(sizeof(long)/sizeof(Exponent_t)); 2695 ord_struct.data.syz.limit=0; 2696 o[place/(sizeof(long)/sizeof(Exponent_t))]=-1; 2697 prev_ord=-1; 2698 place++; 2699 rO_Align(place); 2700 } 2701 2589 2702 BOOLEAN rComplete(ring r, int force) 2590 2703 { … … 2743 2856 case ringorder_S: 2744 2857 rO_Syzcomp(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 2858 r->pVarLowIndex=j; 2859 typ_i++; 2860 break; 2861 2862 case ringorder_s: 2863 rO_Syz(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 2745 2864 r->pVarLowIndex=j; 2746 2865 typ_i++; … … 3017 3136 *currComponents = r->typ[1].data.syzcomp.Components; 3018 3137 } 3138 3139 ring rAddSyzComp(ring r) 3140 { 3141 if (r->order[0]==ringorder_c) 3142 return currRing; 3143 3144 ring res=rCopy(r); 3145 if (res->qideal!=NULL) 3146 { 3147 idDelete(&(res->qideal)); 3148 } 3149 rUnComplete(res); 3150 int i=rBlocks(r); 3151 Free((ADDRESS)res->order,i*sizeof(int)); 3152 res->order=(int *)Alloc((i+1)*sizeof(int)); 3153 memcpy(&(res->order[1]),&(r->order[0]),i*sizeof(int)); 3154 Free((ADDRESS)res->block0,i*sizeof(int)); 3155 res->block0=(int *)Alloc((i+1)*sizeof(int)); 3156 memcpy(&(res->block0[1]),&(r->block0[0]),i*sizeof(int)); 3157 Free((ADDRESS)res->block1,i*sizeof(int)); 3158 res->block1=(int *)Alloc((i+1)*sizeof(int)); 3159 memcpy(&(res->block1[1]),&(r->block1[0]),i*sizeof(int)); 3160 res->order[0]=ringorder_s; 3161 rComplete(res); 3162 rChangeCurrRing(res,TRUE); 3163 if(r->qideal!=NULL) 3164 { 3165 res->qideal=idInit(IDELEMS(r->qideal),1); 3166 for(i=IDELEMS(r->qideal)-1;i>=0;i--) 3167 { 3168 res->qideal->m[i]=pPermPoly(r->qideal->m[i],NULL,r,NULL,0); 3169 } 3170 } 3171 return res; 3172 } -
Singular/ring.h
r9a384e re960943 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.3 5 1999-09-29 17:19:05Singular Exp $ */9 /* $Id: ring.h,v 1.36 1999-10-14 12:50:28 Singular Exp $ */ 10 10 11 11 /* includes */ … … 26 26 void rKill(ring r); 27 27 ring rCopy(ring r); 28 ring rAddSyzComp(ring r); 28 29 29 30 #ifdef PDEBUG … … 126 127 ringorder_M, 127 128 ringorder_S, 129 ringorder_s, 128 130 ringorder_lp, 129 131 ringorder_dp, -
Singular/structs.h
r9a384e re960943 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.2 6 1999-09-29 13:42:54Singular Exp $ */6 /* $Id: structs.h,v 1.27 1999-10-14 12:50:29 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 124 124 ro_cp, // ordering duplicates variables 125 125 ro_syzcomp, // ordering indicates "subset" of component number 126 ro_syz, // ordering with component number >syzcomp is lower 126 127 ro_none 127 128 } … … 168 169 typedef struct sro_syzcomp sro_syzcomp; 169 170 171 // ordering with component number >syzcomp is lower 172 struct sro_syz 173 { 174 short place; // where the index is stored (in L) 175 int limit; // syzcomp 176 }; 177 178 typedef struct sro_syz sro_syz; 170 179 171 180 struct sro_ord … … 178 187 sro_cp cp; 179 188 sro_syzcomp syzcomp; 189 sro_syz syz; 180 190 } data; 181 191 };
Note: See TracChangeset
for help on using the changeset viewer.