Changeset d5042e in git
- Timestamp:
- Jun 22, 2009, 5:17:37 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 587cc52fbea6eb31ce24d13c81748bbe2743326e
- Parents:
- 08c2d636b6e8ba70134c33364e4e4a463aac2d13
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r08c2d6 rd5042e 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-06- 19 11:22:06$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.6 3 2009-06-19 11:22:06monerjan Exp $6 $Id: gfan.cc,v 1.6 3 2009-06-19 11:22:06monerjan Exp $4 $Date: 2009-06-22 15:17:37 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.64 2009-06-22 15:17:37 monerjan Exp $ 6 $Id: gfan.cc,v 1.64 2009-06-22 15:17:37 monerjan Exp $ 7 7 */ 8 8 … … 105 105 // Pointer to next facet. */ 106 106 /* Defaults to NULL. This way there is no need to check explicitly */ 107 this->next=NULL; 108 this->UCN=NULL; 107 this->fNormal=NULL; 108 this->interiorPoint=NULL; 109 this->UCN=0; 109 110 this->codim2Ptr=NULL; 110 111 this->codim=1; //default for (codim-1)-facets 111 this->numCodim2Facets=0; 112 this->flipGB=NULL; 113 this->isIncoming=FALSE; 114 this->next=NULL; 115 this->codim2Ptr=NULL; 116 this->numCodim2Facets=0; 117 this->flipRing=NULL; 112 118 } 113 119 … … 117 123 { 118 124 this->next=NULL; 119 this->UCN= NULL;125 this->UCN=0; 120 126 this->codim2Ptr=NULL; 121 127 if(n>1) … … 489 495 // End of var declaration 490 496 #ifdef gfan_DEBUG 491 cout << "The Groebner basis has " << lengthGB << " elements" << endl;492 cout << "The current ring has " << numvar << " variables" << endl;497 // cout << "The Groebner basis has " << lengthGB << " elements" << endl; 498 // cout << "The current ring has " << numvar << " variables" << endl; 493 499 #endif 494 500 cols = numvar; … … 502 508 } 503 509 #ifdef gfan_DEBUG 504 cout << "rows=" << rows << endl;505 cout << "Will create a " << rows << " x " << cols << " matrix to store inequalities" << endl;510 // cout << "rows=" << rows << endl; 511 // cout << "Will create a " << rows << " x " << cols << " matrix to store inequalities" << endl; 506 512 #endif 507 513 dd_rowrange aktmatrixrow=0; // needed to store the diffs of the expvects in the rows of ddineq … … 518 524 pCompCount=pLength(aktpoly); //How many terms does aktpoly consist of? 519 525 #ifdef gfan_DEBUG 520 cout << "Poly No. " << i << " has " << pCompCount << " components" << endl;526 // cout << "Poly No. " << i << " has " << pCompCount << " components" << endl; 521 527 #endif 522 528 … … 585 591 /*The pointer *fRoot should be the return value of this function*/ 586 592 facet *fRoot = new facet(); //instantiate new facet 593 fRoot->setUCN(this->getUCN()); 587 594 this->facetPtr = fRoot; //set variable facetPtr of class gcone to first facet 588 595 facet *fAct; //instantiate pointer to active facet … … 597 604 foo = mpq_get_d(ddineq->matrix[kk][jj]); 598 605 #ifdef gfan_DEBUG 599 std::cout << "fAct is " << foo << " at " << fAct << std::endl;606 // std::cout << "fAct is " << foo << " at " << fAct << std::endl; 600 607 #endif 601 608 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load … … 608 615 intvec *ivCanonical = new intvec(load->length()); 609 616 (*ivCanonical)[jj]=1; 610 cout << "dotProd=" << dotProduct(*load,*ivCanonical) << endl;617 // cout << "dotProd=" << dotProduct(*load,*ivCanonical) << endl; 611 618 if (dotProduct(*load,*ivCanonical)<0) 612 619 //if (ivMult(load,ivCanonical)<0) … … 624 631 else 625 632 { /*Now load should be full and we can call setFacetNormal*/ 633 //NOTE Check whether another facet is needed at all. Otherwise 634 //this results in one facet too much being constructed! 626 635 fAct->setFacetNormal(load); 627 636 fAct->next = new facet(); 628 637 fAct=fAct->next; //this should definitely not be called in the above while-loop :D 638 fAct->setUCN(this->getUCN()); 629 639 this->numFacets++; 630 640 }//if (isFlippable==FALSE) … … 693 703 ddpolyh=dd_DDMatrix2Poly(ddakt, &err); 694 704 P=dd_CopyGenerators(ddpolyh); 695 dd_WriteMatrix(stdout,P);705 // dd_WriteMatrix(stdout,P); 696 706 697 707 /* We loop through each row of P … … 831 841 ina=idrCopyR(initialForm,srcRing); 832 842 #ifdef gfan_DEBUG 833 cout << "ina=";834 idShow(ina); cout << endl;843 // cout << "ina="; 844 // idShow(ina); cout << endl; 835 845 #endif 836 846 ideal H; … … 1580 1590 gcone *gcAct; 1581 1591 gcAct = &gcRoot; 1582 gcone *gcPtr; 1592 gcone *gcPtr; //Pointer to end of linked list of cones 1583 1593 gcPtr = &gcRoot; 1594 gcone *gcNext; //Pointer to next cone to be visited 1595 gcNext = &gcRoot; 1596 gcone *gcHead; 1597 gcHead = &gcRoot; 1584 1598 1585 1599 facet *fAct; … … 1611 1625 SearchListAct = SearchListRoot; //Set to beginning of list 1612 1626 1613 fAct = gcAct->facetPtr; 1614 if(areEqual(fAct->getFacetNormal(),fAct->next->getFacetNormal())) 1615 { 1616 cout <<"HI" << endl; 1617 } 1618 1619 gcAct->writeConeToFile(*gcAct); 1627 fAct = gcAct->facetPtr; 1628 //gcAct->writeConeToFile(*gcAct); 1620 1629 1621 1630 /*End of initialisation*/ … … 1626 1635 */ 1627 1636 while(SearchListAct->next!=NULL) 1628 {//NOTE See to it that the cone is only changed after ALL facets have been flipped! 1629 //As of now this is not the case! 1630 int flag=1; 1637 {//NOTE See to it that the cone is only changed after ALL facets have been flipped! 1631 1638 fAct = SearchListAct; 1632 1639 //while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) ) … … 1634 1641 { 1635 1642 gcAct->flip(gcAct->gcBasis,fAct); 1636 ring rTmp=rCopy( SearchListAct->flipRing);1643 ring rTmp=rCopy(fAct->flipRing); 1637 1644 rComplete(rTmp); 1638 1645 rChangeCurrRing(rTmp); 1639 gcone *gcTmp = new gcone::gcone(*gcAct,* SearchListAct);1646 gcone *gcTmp = new gcone::gcone(*gcAct,*fAct); 1640 1647 gcTmp->getConeNormals(gcTmp->gcBasis, FALSE); 1641 1648 gcTmp->getCodim2Normals(*gcTmp); 1642 /*add facets to SLA here*/ 1649 gcTmp->normalize(); 1650 /*add facets to SLA here*/ 1651 gcTmp->enqueueNewFacets(*SearchListRoot); 1643 1652 rChangeCurrRing(gcAct->baseRing); 1644 1653 gcPtr->next=gcTmp; 1645 if(flag==1)1646 gcAct->next=gcTmp;1647 1654 gcPtr=gcPtr->next; 1648 1655 if(fAct->getUCN() == fAct->next->getUCN()) … … 1652 1659 else 1653 1660 break; 1654 flag++;1655 }while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );1656 if (fAct->next!=NULL)1657 { 1658 SearchListAct=fAct->next;1659 ring r=rCopy(SearchListAct->flipRing);1660 rComplete(r);1661 rChangeCurrRing(r);1662 gc Act = gcAct->next;1661 }while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) ); 1662 gcNext = gcHead; 1663 while(gcNext->next!=NULL) 1664 { 1665 if(gcNext->getUCN() > gcNext->next->getUCN() ) 1666 { 1667 gcAct = gcNext->next; 1668 } 1669 gcNext = gcNext->next; 1663 1670 } 1664 else 1665 { 1666 SearchListAct=NULL; 1667 } 1671 SearchListAct = SearchListAct->next; 1672 // if (fAct->next!=NULL) 1673 // { 1674 // SearchListAct=fAct->next; 1675 // ring r=rCopy(SearchListAct->flipRing); 1676 // rComplete(r); 1677 // rChangeCurrRing(r); 1678 // gcAct = gcAct->next; 1679 // } 1680 // else 1681 // { 1682 // SearchListAct=NULL; 1683 // } 1668 1684 1669 } 1685 } 1686 1687 // while(SearchListAct->next!=NULL) 1688 // { 1689 // fAct = SearchListAct; 1690 // do 1691 // { 1692 // gcAct->flip(gcAct->gcBasis,fAct); 1693 // ring rTmp = rCopy(fAct->flipRing); 1694 // rComplete(rTmp); 1695 // rChangeCurrRing(rTmp); 1696 // gcone *gcTmp = new gcone(*gcAct,*fAct); 1697 // gcTmp->getConeNormals(gcTmp->gcBasis,FALSE); 1698 // gcTmp->getCodim2Normals(*gcTmp); 1699 // gcPtr->next = gcTmp; 1700 // gcPtr = gcPtr->next; 1701 // /*add facets to SLA here*/ 1702 // rChangeCurrRing(gcAct->baseRing); 1703 // fAct = fAct->next; 1704 // }while( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN())); 1705 // SearchListAct = SearchListAct->next;//fAct; 1706 // } 1707 1708 // while(SearchListAct->next!=NULL) 1709 // { 1710 // gcAct->flip(gcAct->gcBasis,SearchListAct); 1711 // ring rTmp=rCopy(fAct->flipRing); 1712 // rComplete(rTmp); 1713 // rChangeCurrRing(rTmp); 1714 // gcone *gcTmp = new gcone(*gcAct,*SearchListAct); 1715 // gcTmp->getConeNormals(gcTmp->gcBasis,FALSE); 1716 // gcTmp->getCodim2Normals(*gcTmp); 1717 // rChangeCurrRing(gcAct->baseRing); 1718 // SearchListAct = SearchListAct->next; 1719 // 1720 // //gcone *gcNew = new gcone(SearchListAct->flipRing,SearchListAct->flipGB); 1721 // //gcAct = gcNew; 1722 // } 1670 1723 1671 1724 //NOTE Hm, comment in and get a crash for free... … … 1776 1829 } 1777 1830 } 1831 /** 1832 * Takes ptr to search list root 1833 */ 1834 void enqueueNewFacets(facet &f) 1835 { 1836 facet *slAct; //called with f=SearchListRoot 1837 slAct = &f; 1838 facet *slEnd; //Pointer to end of SLA 1839 slEnd = &f; 1840 facet *fAct; 1841 fAct = this->facetPtr; 1842 facet *codim2Act; 1843 codim2Act = this->facetPtr->codim2Ptr; 1844 while(slEnd->next!=NULL) 1845 { 1846 slEnd=slEnd->next; 1847 } 1848 /*1st step: compare facetNormals*/ 1849 intvec *fNormal = new intvec(this->numVars); 1850 intvec *f2Normal = new intvec(this->numVars); 1851 intvec *slNormal = new intvec(this->numVars); 1852 intvec *sl2Normal = new intvec(this->numVars); 1853 while(slAct->next!=NULL) 1854 { 1855 slNormal = slAct->getFacetNormal(); 1856 fAct = this->facetPtr; 1857 while(fAct->next!=NULL) 1858 { 1859 fNormal = fAct->getFacetNormal(); 1860 if(!isParallel(fNormal,slNormal)) 1861 { 1862 slEnd->next = new facet(); 1863 slEnd = slEnd->next; 1864 slEnd->setUCN(this->getUCN()); 1865 slEnd->setFacetNormal(fNormal); 1866 //memcpy(slEnd,fAct,sizeof(facet)); 1867 } 1868 fAct = fAct->next; 1869 } 1870 slAct = slAct->next; 1871 } 1872 // delete sl2Normal; 1873 // delete slNormal; 1874 // delete f2Normal; 1875 // delete fNormal; 1876 }//addC2N 1778 1877 1779 1878 /** \brief Compute the gcd of two ints
Note: See TracChangeset
for help on using the changeset viewer.