Changeset cb0fbe in git for kernel/kstd2.cc
- Timestamp:
- Jun 24, 2007, 6:44:42 PM (17 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 502966ccc93312cccaa355b8008b73f25689ad2a
- Parents:
- 2948552e9bc6affb02b4648d16ae45f6040d286d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kstd2.cc
r2948552 rcb0fbe 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.4 4 2007-05-11 10:48:03 wienandExp $ */4 /* $Id: kstd2.cc,v 1.45 2007-06-24 16:44:40 levandov Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 30 30 #endif 31 31 // #include "timer.h" 32 33 /* shiftgb stuff */ 34 #include "shiftgb.h" 32 35 33 36 // return -1 if no divisor is found … … 1430 1433 } 1431 1434 1435 /* shiftgb stuff */ 1436 // #ifdef KDEBUG 1437 // static int bba_count = 0; 1438 // #endif 1439 1440 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV) 1441 { 1442 #ifdef KDEBUG 1443 bba_count++; 1444 int loop_count = 0; 1445 #endif 1446 om_Opts.MinTrack = 5; 1447 int srmax,lrmax, red_result = 1; 1448 int olddeg,reduc; 1449 int hilbeledeg=1,hilbcount=0,minimcnt=0; 1450 BOOLEAN withT = FALSE; 1451 1452 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ 1453 initBuchMoraPos(strat); 1454 initHilbCrit(F,Q,&hilb,strat); 1455 initBbaShift(F,strat); /* TODOING */ 1456 /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ 1457 /*Shdl=*/initBuchMora(F, Q,strat); 1458 if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank); 1459 srmax = strat->sl; 1460 reduc = olddeg = lrmax = 0; 1461 1462 #ifndef NO_BUCKETS 1463 if (!TEST_OPT_NOT_BUCKETS) 1464 strat->use_buckets = 1; 1465 #endif 1466 1467 // redtailBBa against T for inhomogenous input 1468 if (!K_TEST_OPT_OLDSTD) 1469 withT = ! strat->homog; 1470 1471 // strat->posInT = posInT_pLength; 1472 kTest_TS(strat); 1473 1474 #ifdef HAVE_TAIL_RING 1475 kStratInitChangeTailRing(strat); 1476 #endif 1477 1478 /* compute------------------------------------------------------- */ 1479 while (strat->Ll >= 0) 1480 { 1481 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ 1482 #ifdef KDEBUG 1483 loop_count++; 1484 if (TEST_OPT_DEBUG) messageSets(strat); 1485 #endif 1486 if (strat->Ll== 0) strat->interpt=TRUE; 1487 if (TEST_OPT_DEGBOUND 1488 && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) 1489 || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) 1490 { 1491 /* 1492 *stops computation if 1493 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then 1494 *a predefined number Kstd1_deg 1495 */ 1496 while ((strat->Ll >= 0) 1497 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL) 1498 && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) 1499 || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))) 1500 ) 1501 deleteInL(strat->L,&strat->Ll,strat->Ll,strat); 1502 if (strat->Ll<0) break; 1503 else strat->noClearS=TRUE; 1504 } 1505 /* picks the last element from the lazyset L */ 1506 strat->P = strat->L[strat->Ll]; 1507 strat->Ll--; 1508 1509 if (pNext(strat->P.p) == strat->tail) 1510 { 1511 // deletes the short spoly 1512 pLmFree(strat->P.p); 1513 strat->P.p = NULL; 1514 poly m1 = NULL, m2 = NULL; 1515 1516 // check that spoly creation is ok 1517 while (strat->tailRing != currRing && 1518 !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) 1519 { 1520 assume(m1 == NULL && m2 == NULL); 1521 // if not, change to a ring where exponents are at least 1522 // large enough 1523 kStratChangeTailRing(strat); 1524 } 1525 // create the real one 1526 ksCreateSpoly(&(strat->P), NULL, strat->use_buckets, 1527 strat->tailRing, m1, m2, strat->R); 1528 } 1529 else if (strat->P.p1 == NULL) 1530 { 1531 if (strat->minim > 0) 1532 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); 1533 // for input polys, prepare reduction 1534 strat->P.PrepareRed(strat->use_buckets); 1535 } 1536 1537 if (strat->P.p == NULL && strat->P.t_p == NULL) 1538 { 1539 red_result = 0; 1540 } 1541 else 1542 { 1543 if (TEST_OPT_PROT) 1544 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), 1545 &olddeg,&reduc,strat, red_result); 1546 1547 /* reduction of the element choosen from L */ 1548 red_result = strat->red(&strat->P,strat); 1549 } 1550 1551 // reduction to non-zero new poly 1552 if (red_result == 1) 1553 { 1554 /* statistic */ 1555 if (TEST_OPT_PROT) PrintS("s"); 1556 1557 // get the polynomial (canonicalize bucket, make sure P.p is set) 1558 strat->P.GetP(strat->lmBin); 1559 1560 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); 1561 1562 // reduce the tail and normalize poly 1563 if (TEST_OPT_INTSTRATEGY) 1564 { 1565 strat->P.pCleardenom(); 1566 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 1567 { 1568 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); 1569 strat->P.pCleardenom(); 1570 } 1571 } 1572 else 1573 { 1574 strat->P.pNorm(); 1575 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 1576 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); 1577 } 1578 1579 #ifdef KDEBUG 1580 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} 1581 #endif 1582 1583 // min_std stuff 1584 if ((strat->P.p1==NULL) && (strat->minim>0)) 1585 { 1586 if (strat->minim==1) 1587 { 1588 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); 1589 p_Delete(&strat->P.p2, currRing, strat->tailRing); 1590 } 1591 else 1592 { 1593 strat->M->m[minimcnt]=strat->P.p2; 1594 strat->P.p2=NULL; 1595 } 1596 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) 1597 pNext(strat->M->m[minimcnt]) 1598 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), 1599 strat->tailRing, currRing, 1600 currRing->PolyBin); 1601 minimcnt++; 1602 } 1603 1604 // enter into S, L, and T 1605 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) 1606 enterT(strat->P, strat); 1607 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); 1608 // posInS only depends on the leading term 1609 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) 1610 { 1611 strat->enterS(strat->P, pos, strat, strat->tl); 1612 } 1613 else 1614 { 1615 // strat->P.Delete(); // syzComp test: it is in T 1616 } 1617 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 1618 // Print("[%d]",hilbeledeg); 1619 if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); 1620 if (strat->sl>srmax) srmax = strat->sl; 1621 } 1622 else if (strat->P.p1 == NULL && strat->minim > 0) 1623 { 1624 p_Delete(&strat->P.p2, currRing, strat->tailRing); 1625 } 1626 #ifdef KDEBUG 1627 memset(&(strat->P), 0, sizeof(strat->P)); 1628 #endif 1629 kTest_TS(strat); 1630 } 1631 #ifdef KDEBUG 1632 if (TEST_OPT_DEBUG) messageSets(strat); 1633 #endif 1634 /* complete reduction of the standard basis--------- */ 1635 if (TEST_OPT_SB_1) 1636 { 1637 int k=1; 1638 int j; 1639 while(k<=strat->sl) 1640 { 1641 j=0; 1642 loop 1643 { 1644 if (j>=k) break; 1645 clearS(strat->S[j],strat->sevS[j],&k,&j,strat); 1646 j++; 1647 } 1648 k++; 1649 } 1650 } 1651 1652 if (TEST_OPT_REDSB) 1653 { 1654 completeReduce(strat); 1655 if (strat->completeReduce_retry) 1656 { 1657 // completeReduce needed larger exponents, retry 1658 // to reduce with S (instead of T) 1659 // and in currRing (instead of strat->tailRing) 1660 cleanT(strat);strat->tailRing=currRing; 1661 int i; 1662 for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1; 1663 completeReduce(strat); 1664 } 1665 } 1666 1667 /* release temp data-------------------------------- */ 1668 exitBuchMora(strat); 1669 if (TEST_OPT_WEIGHTM) 1670 { 1671 pRestoreDegProcs(pFDegOld, pLDegOld); 1672 if (ecartWeights) 1673 { 1674 omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short)); 1675 ecartWeights=NULL; 1676 } 1677 } 1678 if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); 1679 if (Q!=NULL) updateResult(strat->Shdl,Q,strat); 1680 return (strat->Shdl); 1681 } 1682 1683 ideal freegb(ideal I, int uptodeg, int lVblock) 1684 { 1685 /* todo main call */ 1686 1687 kStrategy strat = new skStrategy; 1688 /* ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV) */ 1689 /* at the moment: 1690 - no quotient (check) 1691 - no *w, no *hilb 1692 */ 1693 1694 ideal RS = bbaShift(I,NULL, NULL, NULL, strat, uptodeg, lVblock); 1695 return(RS); 1696 } 1697
Note: See TracChangeset
for help on using the changeset viewer.