Changeset dcf8b4b in git
- Timestamp:
- Dec 1, 2009, 5:47:46 PM (14 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 1a4313bf84d3433b6a113589a965c6ea1766c8ce
- Parents:
- 1d37196eda0b0e8bea2d9be3b21f429dafca15d1
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r1d37196 rdcf8b4b 178 178 if(this->codim2Ptr!=NULL) 179 179 delete this->codim2Ptr; 180 //if(this->flipGB!=NULL)181 //idDelete((ideal *)&this->flipGB);182 //if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)183 //rDelete(this->flipRing);180 if(this->flipGB!=NULL) 181 idDelete((ideal *)&this->flipGB); 182 if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb) 183 rDelete(this->flipRing); 184 184 // this->flipRing=NULL; 185 this->prev=NULL; 186 this->next=NULL; 185 187 //this=NULL; 186 188 } … … 193 195 int notParallelCtr=0; 194 196 int ctr=0; 195 intvec* fNormal; // = new intvec(pVariables);196 intvec* sNormal; // = new intvec(pVariables);197 intvec* fNormal; //No new since ivCopy and therefore getFacetNormal return a new 198 intvec* sNormal; 197 199 fNormal = f->getFacetNormal(); 198 200 sNormal = s->getFacetNormal(); … … 203 205 facet* f2Act; 204 206 facet* s2Act; 205 f2Act = f->codim2Ptr; 206 intvec* f2Normal; 207 intvec* s2Normal; 207 f2Act = f->codim2Ptr; 208 208 ctr=0; 209 209 while(f2Act!=NULL) 210 210 { 211 intvec* f2Normal; 211 212 f2Normal = f2Act->getFacetNormal(); 212 213 s2Act = s->codim2Ptr; 213 214 while(s2Act!=NULL) 214 215 { 216 intvec* s2Normal; 215 217 s2Normal = s2Act->getFacetNormal(); 216 218 bool foo=areEqual(f2Normal,s2Normal); 217 219 if(foo) 218 220 ctr++; 219 s2Act = s2Act->next; 221 s2Act = s2Act->next; 222 delete s2Normal; 220 223 } 224 delete f2Normal; 221 225 f2Act = f2Act->next; 222 } 223 } 226 } 227 } 228 delete fNormal; 229 delete sNormal; 224 230 if(ctr==f->numCodim2Facets) 225 231 res=TRUE; … … 239 245 { 240 246 return ivCopy(this->fNormal); 247 // return this->fNormal; 241 248 } 242 249 … … 307 314 codim2Act = this->codim2Ptr; 308 315 intvec *fNormal; 309 fNormal = this->getFacetNormal(); 310 intvec *f2Normal; 316 fNormal = this->getFacetNormal(); 311 317 cout << "=======================" << endl; 312 318 cout << "Facet normal = ("; … … 317 323 while(codim2Act!=NULL) 318 324 { 325 intvec *f2Normal; 319 326 f2Normal = codim2Act->getFacetNormal(); 320 327 cout << "("; … … 322 329 cout << ")" << endl; 323 330 codim2Act = codim2Act->next; 331 delete f2Normal; 324 332 } 325 333 cout << "=======================" << endl; 334 delete fNormal; 326 335 } 327 336 … … 458 467 * This is mainly for debugging purposes. Usually called from within gdb 459 468 */ 460 void gcone::showFacets( short codim)469 void gcone::showFacets(const short codim) 461 470 { 462 471 facet *f; … … 469 478 f = this->facetPtr->codim2Ptr; 470 479 break; 471 } 472 473 intvec *iv; 480 } 474 481 while(f!=NULL) 475 482 { 483 intvec *iv; 476 484 iv = f->getFacetNormal(); 477 485 cout << "("; … … 481 489 else 482 490 cout << ") "; 491 delete iv; 483 492 f=f->next; 484 493 } … … 493 502 facet *codim2Act; 494 503 codim2Act = fAct->codim2Ptr; 495 intvec *fNormal; 496 intvec *f2Normal; 504 497 505 cout << endl; 498 506 while(fAct!=NULL) 499 507 { 508 intvec *fNormal; 500 509 fNormal=fAct->getFacetNormal(); 501 510 cout << "("; … … 505 514 else 506 515 cout << ")* "; 516 delete fNormal; 507 517 codim2Act = fAct->codim2Ptr; 508 518 cout << " Codim2: "; 509 519 while(codim2Act!=NULL) 510 520 { 521 intvec *f2Normal; 511 522 f2Normal = codim2Act->getFacetNormal(); 512 523 cout << "("; 513 524 f2Normal->show(1,0); 514 525 cout << ") "; 526 delete f2Normal; 515 527 codim2Act = codim2Act->next; 516 528 } … … 520 532 } 521 533 522 void gcone::idDebugPrint( ideal const&I)534 void gcone::idDebugPrint(const ideal &I) 523 535 { 524 536 int numElts=IDELEMS(I); … … 533 545 } 534 546 535 void gcone::invPrint( ideal const&I)547 void gcone::invPrint(const ideal &I) 536 548 { 537 549 // int numElts=IDELEMS(I); … … 545 557 } 546 558 547 bool gcone::isMonomial( ideal const&I)559 bool gcone::isMonomial(const ideal &I) 548 560 { 549 561 bool res = TRUE; … … 596 608 * an interior point of the cone. 597 609 */ 598 void gcone::getConeNormals( ideal const&I, bool compIntPoint)610 void gcone::getConeNormals(const ideal &I, bool compIntPoint) 599 611 { 600 612 poly aktpoly; … … 648 660 * Quote: [...] every non-zero spoly should have at least one of its terms in inv(G) 649 661 */ 650 ideal initialForm=idInit(IDELEMS(I),1);662 // ideal initialForm=idInit(IDELEMS(I),1); 651 663 intvec *gamma=new intvec(this->numVars); 652 664 int falseGammaCounter=0; … … 656 668 for(int ii=0;ii<ddineq->rowsize;ii++) 657 669 { 670 ideal initialForm=idInit(IDELEMS(I),1); 658 671 //read row ii into gamma 659 672 double tmp; … … 711 724 p=pNext(p); 712 725 }//while 726 pDelete(&p); 727 pDelete(&q); 713 728 if(isMaybeFacet==FALSE) 714 729 { … … 734 749 }//for jj 735 750 _start:; 751 idDelete(&L); 736 752 delete P; 753 idDelete(&initialForm); 737 754 //idDelete(L); 738 755 }//for(ii<ddineq-rowsize 756 delete gamma; 739 757 int offset=0;//needed for correction of redRowsArray[ii] 740 758 for( int ii=0;ii<num_elts;ii++ ) … … 833 851 { 834 852 WerrorS ("Only non-flippable facets. Terminating...\n"); 835 exit(-1);//Bit harsh maybe...853 // exit(-1);//Bit harsh maybe... 836 854 } 837 855 … … 856 874 this->setIntPoint(iv); //stores the interior point in gcone::ivIntPt 857 875 delete iv; 876 dd_FreeMatrix(posRestr); 858 877 } 859 //Clean up but don't delete the return value! 878 //Clean up but don't delete the return value! 860 879 dd_FreeMatrix(ddineq); 861 880 set_free(ddredrows); … … 976 995 void gcone::flip(ideal gb, facet *f) //Compute "the other side" 977 996 { 978 intvec *fNormal = new intvec(this->numVars); //facet normal, check for parallelity997 intvec *fNormal;// = new intvec(this->numVars); //facet normal, check for parallelity 979 998 fNormal = f->getFacetNormal(); //read this->fNormal; 980 999 981 1000 // std::cout << "running gcone::flip" << std::endl; 982 std::cout << "flipping UCN " << this->getUCN() << endl;983 cout << "over facet (";984 fNormal->show(1,0);985 cout << ") with UCN " << f->getUCN();986 std::cout << std::endl;1001 // std::cout << "flipping UCN " << this->getUCN() << endl; 1002 // cout << "over facet ("; 1003 // fNormal->show(1,0); 1004 // cout << ") with UCN " << f->getUCN(); 1005 // std::cout << std::endl; 987 1006 if(this->getUCN() != f->getUCN()) 988 1007 { … … 1014 1033 if( (srcRing->order[0]!=ringorder_a)) 1015 1034 { 1016 tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal)); 1035 intvec *iv = new intvec(this->numVars); 1036 iv = ivNeg(fNormal); 1037 // tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal)); 1038 tmpRing=rCopyAndAddWeight(srcRing,iv); 1039 delete iv; 1017 1040 } 1018 1041 else … … 1030 1053 rComplete(tmpRing); 1031 1054 } 1032 delete fNormal;1055 delete fNormal; 1033 1056 rChangeCurrRing(tmpRing); 1034 1057 … … 1051 1074 //H is needed further below, so don't idDelete here 1052 1075 srcRing_HH=ffG(srcRing_H,this->gcBasis); 1053 //idDelete(&srcRing_H);1076 idDelete(&srcRing_H); 1054 1077 1055 1078 /*Substep 2.2.1 … … 1194 1217 ideal dstRing_I; 1195 1218 dstRing_I=idrCopyR(srcRing_HH,srcRing); 1196 //idDelete(&srcRing_HH); //Hmm.... causes trouble1219 idDelete(&srcRing_HH); //Hmm.... causes trouble - no more 1197 1220 //dstRing_I=idrCopyR(inputIdeal,srcRing); 1198 1221 BITSET save=test; … … 1218 1241 f->flipRing=rCopy(dstRing); //store the ring on the other side 1219 1242 //#ifdef gfan_DEBUG 1220 //cout << "Flipped GB is UCN " << counter+1 << ":" << endl;1243 cout << "Flipped GB is UCN " << counter+1 << ":" << endl; 1221 1244 // this->idDebugPrint(dstRing_I); 1222 1245 // cout << endl; … … 1234 1257 { 1235 1258 intvec *check = new intvec(this->numVars); 1236 poly initialFormElement [IDELEMS(gb)];1237 poly aktpoly;1259 poly initialFormElement;//[IDELEMS(gb)]; 1260 // poly aktpoly; 1238 1261 1239 1262 for (int ii=0;ii<IDELEMS(gb);ii++) 1240 1263 { 1241 aktpoly = pCopy((poly)gb->m[ii]); 1264 // aktpoly = pCopy((poly)gb->m[ii]); 1265 poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly) 1242 1266 int *v=(int *)omAlloc((this->numVars+1)*sizeof(int)); 1243 1267 int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int)); 1244 1268 pGetExpV(aktpoly,leadExpV); //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p) 1245 initialFormElement[ii]=pHead(aktpoly); 1269 // initialFormElement[ii]=pHead(aktpoly); 1270 initialFormElement=pHead(aktpoly); 1246 1271 1247 1272 while(pNext(aktpoly)!=NULL) /*loop trough terms and check for parallelity*/ … … 1257 1282 (*check)[jj]=v[jj+1]-leadExpV[jj+1]; 1258 1283 } 1259 #ifdef gfan_DEBUG1260 // cout << "check=";1261 // check->show();1262 // cout << endl;1263 #endif1264 1284 if (isParallel(*check,fNormal)) //pass *check when 1265 1285 { 1266 1286 //Found a parallel vector. Add it 1267 initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly)); 1287 // initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly)); 1288 initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly)); 1268 1289 } 1269 1290 }//while … … 1274 1295 #endif 1275 1296 /*Now initialFormElement must be added to (ideal)initialForm */ 1276 initialForm->m[ii]=pCopy(initialFormElement[ii]); 1277 pDelete(&initialFormElement[ii]); 1297 // initialForm->m[ii]=pCopy(initialFormElement[ii]); 1298 // pDelete(&initialFormElement[ii]); 1299 initialForm->m[ii]=pCopy(initialFormElement); 1300 pDelete(&initialFormElement); 1278 1301 omFree(leadExpV); 1279 1302 omFree(v); 1280 1303 }//for 1281 1304 delete check; 1282 pDelete(&aktpoly);1305 // pDelete(&aktpoly); 1283 1306 } 1284 1307 … … 1297 1320 */ 1298 1321 //NOTE: use kNF or kNF2 instead of restOfDivision 1299 ideal gcone::ffG( ideal const &H, ideal const&G)1322 ideal gcone::ffG(const ideal &H, const ideal &G) 1300 1323 { 1301 1324 // cout << "Entering ffG" << endl; … … 1331 1354 *\return void 1332 1355 */ 1333 void gcone::getGB( ideal const&inputIdeal)1356 void gcone::getGB(const ideal &inputIdeal) 1334 1357 { 1335 1358 BITSET save=test; … … 1359 1382 * 1360 1383 */ 1361 int gcone::dotProduct( intvec const &iva, intvec const&ivb)1384 int gcone::dotProduct(const intvec &iva, const intvec &ivb) 1362 1385 { 1363 1386 int res=0; … … 1373 1396 * \f$ \alpha\parallel\beta\Leftrightarrow\langle\alpha,\beta\rangle^2=\langle\alpha,\alpha\rangle\langle\beta,\beta\rangle \f$ 1374 1397 */ 1375 bool gcone::isParallel( intvec const &a, intvec const&b)1398 bool gcone::isParallel(const intvec &a, const intvec &b) 1376 1399 { 1377 1400 int lhs,rhs; … … 1395 1418 * Any rational point is automatically converted into an integer. 1396 1419 */ 1397 void gcone::interiorPoint( dd_MatrixPtr const&M, intvec &iv) //no const &M here since we want to remove redundant rows1420 void gcone::interiorPoint(const dd_MatrixPtr &M, intvec &iv) //no const &M here since we want to remove redundant rows 1398 1421 { 1399 1422 dd_LPPtr lp,lpInt; … … 1498 1521 * 1499 1522 */ 1500 ring gcone::rCopyAndAddWeight( ring const &r, intvec const*ivw)1523 ring gcone::rCopyAndAddWeight(const ring &r, const intvec *ivw) 1501 1524 { 1502 1525 ring res=rCopy0(r); … … 1554 1577 /** \brief Check for equality of two intvecs 1555 1578 */ 1556 bool gcone::areEqual( intvec const &a, intvec const&b)1579 bool gcone::areEqual(const intvec &a, const intvec &b) 1557 1580 { 1558 1581 bool res=TRUE; … … 1626 1649 we must not memcpy them before these ops! 1627 1650 */ 1628 intvec *fNormal;// = new intvec(this->numVars); 1629 intvec *f2Normal;// = new intvec(this->numVars); 1651 1630 1652 facet *codim2Act; codim2Act = NULL; 1631 1653 facet *sl2Root; //sl2Root = new facet(2); … … 1637 1659 if(fAct->isFlippable==TRUE) 1638 1660 { 1661 intvec *fNormal; 1639 1662 fNormal = fAct->getFacetNormal(); 1640 1663 if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable … … 1659 1682 for(int jj=0;jj<fAct->numCodim2Facets;jj++) 1660 1683 { 1684 intvec *f2Normal; 1661 1685 f2Normal = codim2Act->getFacetNormal(); 1662 1686 if(jj==0) … … 1670 1694 sl2Act = sl2Act->next; 1671 1695 sl2Act->setFacetNormal(f2Normal); 1672 } 1696 } 1697 delete f2Normal; 1673 1698 codim2Act = codim2Act->next; 1674 1699 } 1675 1700 fAct = fAct->next; 1676 }//if(fAct->isFlippable==TRUE) 1701 delete fNormal; 1702 }//if(fAct->isFlippable==TRUE) 1677 1703 else {fAct = fAct->next;} 1678 1704 }//End of copying facets into SLA … … 1734 1760 #endif 1735 1761 /*add facets to SLA here*/ 1736 SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot); 1762 SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot); 1737 1763 if(gfanHeuristic==1) 1738 1764 { … … 1744 1770 // idDelete((ideal*)&gcTmp->gcBasis); 1745 1771 } 1746 //#if gfan_DEBUG1772 #if gfan_DEBUG 1747 1773 if(SearchListRoot!=NULL) 1748 1774 gcTmp->showSLA(*SearchListRoot); 1749 //#endif1775 #endif 1750 1776 rChangeCurrRing(gcAct->baseRing); 1751 1777 //rDelete(rTmp); … … 1761 1787 break; 1762 1788 // fAct=fAct->next; 1763 }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) ); 1764 //NOTE Now all neighbouring cones of gcAct have been computed, so we may delete gcAct 1765 gcone *deleteMarker; 1766 deleteMarker=gcAct; 1789 }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) ); 1767 1790 //Search for cone with smallest UCN 1768 1791 gcNext = gcHead; … … 1810 1833 * \param dd_MatrixPtr,intvec 1811 1834 */ 1812 void gcone::makeInt( dd_MatrixPtr const &M, int const line, intvec &n)1835 void gcone::makeInt(const dd_MatrixPtr &M, const int line, intvec &n) 1813 1836 { 1814 mpz_t denom[this->numVars]; 1837 // mpz_t denom[this->numVars]; 1838 mpz_t *denom = new mpz_t[this->numVars]; 1815 1839 for(int ii=0;ii<this->numVars;ii++) 1816 1840 { … … 1838 1862 mpz_set(tmp,kgV); 1839 1863 } 1840 1864 mpz_clear(tmp); 1841 1865 /*Multiply the nominators by kgV*/ 1842 1866 mpq_t qkgV,res; … … 1857 1881 n[ii]=(int)mpz_get_d(mpq_numref(res)); 1858 1882 } 1859 //mpz_clear(denom[this->numVars]);1883 delete [] denom; 1860 1884 mpz_clear(kgV); 1861 1885 mpq_clear(qkgV); mpq_clear(res); … … 1869 1893 void gcone::normalize() 1870 1894 { 1871 int ggT=1; 1895 int *ggT = new int; 1896 *ggT=1; 1872 1897 facet *fAct; 1873 1898 facet *codim2Act; 1874 1899 fAct = this->facetPtr; 1875 1900 codim2Act = fAct->codim2Ptr; 1876 intvec *n = new intvec(this->numVars);1877 1878 1901 // intvec *n = new intvec(this->numVars); 1902 1903 //while(codim2Act->next!=NULL) 1879 1904 while(fAct!=NULL) 1880 1905 { 1881 1906 while(codim2Act!=NULL) 1882 1907 { 1908 intvec *n; 1883 1909 n=codim2Act->getFacetNormal(); 1884 1910 for(int ii=0;ii<this->numVars;ii++) 1885 1911 { 1886 ggT = intgcd(ggT,(*n)[ii]);1912 *ggT = intgcd((*ggT),(*n)[ii]); 1887 1913 } 1888 1914 for(int ii=0;ii<this->numVars;ii++) 1889 1915 { 1890 (*n)[ii] = ((*n)[ii])/ ggT;1916 (*n)[ii] = ((*n)[ii])/(*ggT); 1891 1917 } 1892 1918 codim2Act->setFacetNormal(n); 1893 codim2Act = codim2Act->next; 1919 codim2Act = codim2Act->next; 1920 delete n; 1894 1921 } 1895 1922 fAct = fAct->next; 1896 1923 } 1897 delete n; 1924 delete ggT; 1925 // delete n; 1898 1926 1899 1927 } … … 1952 1980 lengthOfSearchList++; 1953 1981 } 1954 // slEndStatic = slEnd;1955 1982 /*1st step: compare facetNormals*/ 1956 intvec *fNormal=NULL; 1957 // intvec *f2Normal=NULL; 1958 intvec *slNormal=NULL; 1959 // intvec *sl2Normal=NULL; 1983 // intvec *fNormal=NULL; 1984 // intvec *slNormal=NULL; 1960 1985 1961 1986 while(fAct!=NULL) … … 1963 1988 if(fAct->isFlippable==TRUE) 1964 1989 { 1965 // maybe=FALSE;1966 // doNotAdd=TRUE;1990 intvec *fNormal=NULL; 1991 // intvec *slNormal=NULL; 1967 1992 fNormal=fAct->getFacetNormal(); 1968 1993 slAct = slHead; 1969 1994 notParallelCtr=0; 1970 // delete deleteMarker;1971 // deleteMarker=NULL;1972 1995 /*If slAct==NULL and fAct!=NULL 1973 1996 we just copy all remaining facets into SLA*/ … … 1988 2011 slAct = slAct->next; 1989 2012 } 1990 //NOTE Below went into copy constructor1991 // slAct->setFacetNormal(fAct->getFacetNormal());1992 // slAct->setUCN(fAct->getUCN());1993 // slAct->isFlippable=fAct->isFlippable;1994 // facet *f2Copy;1995 // f2Copy = fCopy->codim2Ptr;1996 // sl2Act = slAct->codim2Ptr;1997 // while(f2Copy!=NULL)1998 // {1999 // if(sl2Act==NULL)2000 // {2001 // sl2Act = new facet(2);2002 // slAct->codim2Ptr = sl2Act;2003 // }2004 // else2005 // {2006 // facet *marker;2007 // marker = sl2Act;2008 // sl2Act->next = new facet(2);2009 // sl2Act = sl2Act->next;2010 // sl2Act->prev = marker;2011 // }2012 // sl2Act->setFacetNormal(f2Copy->getFacetNormal());2013 // sl2Act->setUCN(f2Copy->getUCN());2014 // f2Copy = f2Copy->next;2015 // }2016 2013 fCopy = fCopy->next; 2017 2014 } … … 2020 2017 /*End of dumping into SLA*/ 2021 2018 while(slAct!=NULL) 2022 //while(slAct!=slEndStatic->next) 2023 { 2024 // if(deleteMarker!=NULL) 2025 // { 2026 // delete deleteMarker; 2027 // deleteMarker=NULL; 2028 // } 2019 //while(slAct!=slEndStatic->next) 2020 { 2021 intvec *slNormal=NULL; 2029 2022 removalOccured=FALSE; 2030 2023 slNormal = slAct->getFacetNormal(); 2031 //#ifdef gfan_DEBUG2024 #ifdef gfan_DEBUG 2032 2025 cout << "Checking facet ("; 2033 2026 fNormal->show(1,1); … … 2035 2028 slNormal->show(1,1); 2036 2029 cout << ")" << endl; 2037 //#endif2030 #endif 2038 2031 if(areEqual(fAct,slAct)) 2039 2032 { … … 2062 2055 // deleteMarker=NULL; 2063 2056 } 2057 #ifdef gfan_DEBUG 2064 2058 cout << "Removing ("; 2065 2059 fNormal->show(1,1); 2066 2060 cout << ") from list" << endl; 2061 #endif 2062 delete slNormal; 2067 2063 break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct 2068 2064 } … … 2079 2075 // deleteMarker=NULL; 2080 2076 } 2077 delete slNormal; 2081 2078 //if slAct was marked as to be deleted, delete it here! 2082 2079 }//while(slAct!=NULL) … … 2085 2082 //if( (notParallelCtr==lengthOfSearchList ) || doNotAdd==FALSE ) 2086 2083 { 2087 //#ifdef gfan_DEBUG2084 #ifdef gfan_DEBUG 2088 2085 cout << "Adding facet ("; 2089 2086 fNormal->show(1,0); 2090 2087 cout << ") to SLA " << endl; 2091 //#endif2088 #endif 2092 2089 //Add fAct to SLA 2093 2090 facet *marker; … … 2108 2105 slEnd->prev = marker; 2109 2106 //Copy codim2-facets 2110 intvec *f2Normal;2107 // intvec *f2Normal=new intvec(this->numVars); 2111 2108 while(f2Act!=NULL) 2112 2109 { 2110 intvec *f2Normal; 2113 2111 f2Normal=f2Act->getFacetNormal(); 2114 2112 if(slEndCodim2Root==NULL) … … 2126 2124 } 2127 2125 f2Act = f2Act->next; 2126 delete f2Normal; 2128 2127 } 2129 2128 lengthOfSearchList++; 2130 2129 }//if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) || 2131 2130 fAct = fAct->next; 2131 delete fNormal; 2132 // delete slNormal; 2132 2133 }//if(fAct->isFlippable==TRUE) 2133 2134 else … … 2141 2142 /** \brief Compute the gcd of two ints 2142 2143 */ 2143 int gcone::intgcd( int a,int b)2144 int gcone::intgcd(const int a, const int b) 2144 2145 { 2145 2146 int r, p=a, q=b; … … 2160 2161 * 2161 2162 */ 2162 dd_MatrixPtr gcone::facets2Matrix( gcone const&gc)2163 dd_MatrixPtr gcone::facets2Matrix(const gcone &gc) 2163 2164 { 2164 2165 facet *fAct; … … 2184 2185 } 2185 2186 jj++; 2187 delete comp; 2186 2188 fAct=fAct->next; 2187 2189 } … … 2200 2202 * Each section starts with its name in CAPITALS 2201 2203 */ 2202 void gcone::writeConeToFile( gcone const&gc, bool usingIntPoints)2204 void gcone::writeConeToFile(const gcone &gc, bool usingIntPoints) 2203 2205 { 2204 2206 int UCN=gc.UCN; … … 2253 2255 { 2254 2256 intvec *iv; 2255 intvec *iv2;2256 2257 iv=fAct->getFacetNormal(); 2257 2258 f2Act=fAct->codim2Ptr; … … 2267 2268 } 2268 2269 } 2270 delete iv; 2269 2271 while(f2Act!=NULL) 2270 2272 { 2273 intvec *iv2; 2271 2274 iv2=f2Act->getFacetNormal(); 2272 2275 for(int jj=0;jj<iv2->length();jj++) … … 2281 2284 } 2282 2285 } 2286 delete iv2; 2283 2287 f2Act = f2Act->next; 2284 2288 } … … 2303 2307 string strMonom, strCoeff, strCoeffNom, strCoeffDenom; 2304 2308 int gcBasisLength=0; 2305 int intCoeff=1; 2306 int intCoeffNom=1; //better (number) but that's not compatible with stringstream; 2307 int intCoeffDenom=1; 2308 number nCoeff=nInit(1); 2309 number nCoeffNom=nInit(1); 2310 number nCoeffDenom=nInit(1); 2309 // int intCoeff=1; 2310 // int intCoeffNom=1; //better (number) but that's not compatible with stringstream; 2311 // int intCoeffDenom=1; 2312 2311 2313 bool hasCoeffInQ = FALSE; //does the polynomial have rational coeff? 2312 2314 bool hasNegCoeff = FALSE; //or a negative one? … … 2324 2326 ring saveRing=currRing; 2325 2327 rChangeCurrRing(gc->baseRing); 2326 poly strPoly=pInit(); 2327 poly resPoly=pInit(); //The poly to be read in 2328 2328 2329 2329 2330 string::iterator EOL; … … 2344 2345 if(line=="GCBASIS") 2345 2346 { 2347 number nCoeff=nInit(1); 2348 number nCoeffNom=nInit(1); 2349 number nCoeffDenom=nInit(1); 2346 2350 for(int jj=0;jj<gcBasisLength;jj++) 2347 2351 { 2348 2352 getline(gcInputFile,line); 2349 //find out how many terms the poly consists of2350 for(EOL=line.begin(); EOL!=line.end();++EOL)2351 {2352 string s;2353 s=*EOL;2354 if(s=="+" || s=="-")2355 terms++;2356 }2357 2353 //magically convert strings into polynomials 2358 2354 //polys.cc:p_Read 2359 2355 //check until first occurance of + or - 2360 2356 //data or c_str 2357 poly strPoly=pInit(); 2358 poly resPoly=pInit(); //The poly to be read in 2361 2359 while(!line.empty()) 2362 2360 { 2363 // resPoly=pInit();2364 // strPoly=pInit();2365 2361 hasNegCoeff = FALSE; 2366 2362 hasCoeffInQ = FALSE; … … 2387 2383 strMonom.erase(0,found); 2388 2384 strMonom.erase(0,strMonom.find_first_not_of("1234567890/")); 2389 // ss << strCoeffNom;2390 // ss >> intCoeffNom;2391 // nCoeffNom=(snumber*)strCoeffNom.c_str();2392 2385 nRead(strCoeffNom.c_str(), &nCoeffNom); 2393 2386 nRead(strCoeffDenom.c_str(), &nCoeffDenom); 2394 // nCoeffNom=nInit(intCoeffNom);2395 // ss << strCoeffDenom;2396 // ss >> intCoeffDenom;2397 // nCoeffDenom=nInit(intCoeffDenom);2398 // nCoeffDenom=(snumber*)strCoeffNom.c_str();2399 //NOTE NOT SURE WHETHER THIS WILL WORK!2400 //nCoeffNom=nInit(intCoeffNom);2401 // nCoeffDenom=(number)strCoeffDenom.c_str();2402 // nCoeffDenom=(number)strCoeffDenom.c_str();2403 2387 } 2404 2388 else … … 2447 2431 resPoly=pCopy(strPoly); 2448 2432 else 2449 resPoly=pAdd(resPoly,strPoly); 2450 2451 2452 }//while(!line.empty()) 2453 2433 resPoly=pAdd(resPoly,strPoly); 2434 }//while(!line.empty()) 2454 2435 gc->gcBasis->m[jj]=pCopy(resPoly); 2455 resPoly=NULL; //reset 2436 pDelete(&resPoly); //reset 2437 // pDelete(&strPoly); //NOTE Crashes 2456 2438 } 2439 nDelete(&nCoeff); 2440 nDelete(&nCoeffNom); 2441 nDelete(&nCoeffDenom); 2457 2442 break; 2458 2443 } 2459 }//while(!gcInputFile.eof()) 2460 2444 }//while(!gcInputFile.eof()) 2461 2445 gcInputFile.close(); 2462 2446 rChangeCurrRing(saveRing); 2463 2447 } 2464 2448 2465 // static void gcone::idPrint(ideal &I)2466 // {2467 // for(int ii=0;ii<IDELEMS(I);ii++)2468 // {2469 // cout << "_[" << ii << "]=" << I->m[ii] << endl;2470 // }2471 // }2472 2449 ring gcone::getBaseRing() 2473 2450 { … … 2511 2488 l->m[3].rtyp=LIST_CMD; 2512 2489 lists lCodim2List = (lists)omAllocBin(slists_bin); 2513 lCodim2List->Init(gcAct->numFacets); 2514 2490 lCodim2List->Init(gcAct->numFacets); 2515 2491 fAct = gcAct->facetPtr;//fAct->codim2Ptr; 2516 2492 int jj=0; … … 2523 2499 fAct = fAct->next; 2524 2500 } 2525 l->m[3].data=(void*)lCodim2List; 2526 2527 2501 l->m[3].data=(void*)lCodim2List; 2528 2502 l->m[4].rtyp=RING_CMD; 2529 2503 l->m[4].data=(void*)(gcAct->getBaseRing()); … … 2532 2506 res->m[ii].data=(void*)l; 2533 2507 gcAct = gcAct->next; 2534 } 2535 2508 } 2536 2509 return res; 2537 2510 } … … 2545 2518 { 2546 2519 facet *fAct; 2547 intvec *res ;2548 intvec *fNormal = new intvec(gc->numVars);2520 intvec *res=new intvec(this->numVars); 2521 intvec *fNormal; 2549 2522 // int codim=n; 2550 2523 // int bound; … … 2553 2526 { 2554 2527 intvec *m1Res=new intvec(gc->numFacets,gc->numVars,0); 2555 res = m1Res;2528 res = ivCopy(m1Res); 2556 2529 fAct = gc->facetPtr; 2530 delete m1Res; 2557 2531 // bound = gc->numFacets*(this->numVars); 2558 2532 } … … 2561 2535 fAct = f->codim2Ptr; 2562 2536 intvec *m2Res = new intvec(f->numCodim2Facets,gc->numVars,0); 2563 res = m2Res; 2537 res = ivCopy(m2Res); 2538 delete m2Res; 2564 2539 // bound = fAct->numCodim2Facets*(this->numVars); 2565 2540 … … 2576 2551 fAct = fAct->next; 2577 2552 } 2578 2579 2553 delete fNormal; 2580 2554 return *res; … … 2601 2575 method = noRevS; 2602 2576 2603 2604 #ifdef gfan_DEBUG2605 cout << "Now in subroutine gfan" << endl;2606 #endif2607 2577 ring inputRing=currRing; // The ring the user entered 2608 2578 ring rootRing; // The ring associated to the target ordering … … 2624 2594 { 2625 2595 WerrorS("Monomial input - terminating"); 2626 res=gcAct->gcBasis; 2627 //break; 2596 exit(-1); 2597 gcAct->getConeNormals(gcAct->gcBasis); 2598 lResList=lprepareResult(gcAct,1); 2599 dd_free_global_constants; 2600 //This is filthy 2601 return lResList; 2628 2602 } 2629 2603 cout << endl; 2630 gcAct->getConeNormals(gcAct->gcBasis); 2631 gcAct->noRevS(*gcAct); 2604 gcAct->getConeNormals(gcAct->gcBasis); 2605 gcAct->noRevS(*gcAct); 2606 rChangeCurrRing(inputRing); 2632 2607 //res=gcAct->gcBasis; 2633 2608 //Below is a workaround, since gcAct->gcBasis gets deleted in noRevS … … 2655 2630 lResList->m[0].data=(void*)&ires; 2656 2631 } 2657 2632 //gcone::counter=0; 2658 2633 /*Return result*/ 2659 2634 return lResList; -
kernel/gfan.h
r1d37196 rdcf8b4b 170 170 bool isMonomial(ideal const &I); 171 171 intvec *ivNeg(const intvec *iv); 172 int dotProduct( intvec const &iva, intvec const&ivb);172 int dotProduct(const intvec &iva, const intvec &ivb); 173 173 bool isParallel(intvec const &a, intvec const &b); 174 174 bool areEqual(intvec const &a, intvec const &b);
Note: See TracChangeset
for help on using the changeset viewer.