Changeset 224d153 in git
- Timestamp:
- May 29, 2009, 9:52:12 AM (14 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- 3ea5cee1504eb5dced1aa095461b2eafa2c20a37
- Parents:
- 69aadadc4549786f157e7b86a56775084cb15d54
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r69aada r224d153 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-05-2 8 06:27:09$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.5 6 2009-05-28 06:27:09monerjan Exp $6 $Id: gfan.cc,v 1.5 6 2009-05-28 06:27:09monerjan Exp $4 $Date: 2009-05-29 07:52:12 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.57 2009-05-29 07:52:12 monerjan Exp $ 6 $Id: gfan.cc,v 1.57 2009-05-29 07:52:12 monerjan Exp $ 7 7 */ 8 8 … … 77 77 int UCN; 78 78 79 /** \brief The codim of the facet 80 */ 81 int codim; 82 79 83 /** \brief The Groebner basis on the other side of a shared facet 80 84 * … … 90 94 bool isIncoming; //Is the facet incoming or outgoing? 91 95 facet *next; //Pointer to next facet 96 facet *codim2Ptr; //Pointer to (codim-2)-facet. Bit of recursion here ;-) 92 97 //intvec **codim2Normals =(intvec**)omAlloc0(sizeof(intvec*)); //Integer matrix containing the (codim-2)-facets 93 struct c2N{ 94 intvec normal; 95 intvec *next; 96 }; 97 98 98 99 /** The default constructor. Do I need a constructor of type facet(intvec)? */ 99 100 facet() … … 103 104 this->next=NULL; 104 105 this->UCN=NULL; 105 //this->codim2Normals=NULL; 106 this->codim2Ptr=NULL; 107 this->codim=1; //default for (codim-1)-facets 108 } 109 110 /** \brief Constructor for facets of codim >= 2 111 */ 112 facet(int const &n) 113 { 114 this->next=NULL; 115 this->UCN=NULL; 116 this->codim2Ptr=NULL; 117 if(n>1) 118 { 119 this->codim=n; 120 }//NOTE Handle exception here! 106 121 } 107 122 … … 112 127 void setFacetNormal(intvec *iv) 113 128 { 114 this->fNormal = ivCopy(iv); 115 //return; 129 this->fNormal = ivCopy(iv); 116 130 } 117 131 118 132 /** Hopefully returns the facet normal */ 119 133 intvec *getFacetNormal() 120 { 121 //this->fNormal->show(); cout << endl; 134 { 122 135 return this->fNormal; 123 136 } … … 165 178 { 166 179 return this->interiorPoint; 167 } 180 } 168 181 169 182 /*bool isFlippable(intvec &load) … … 251 264 { 252 265 this->next=NULL; 253 this->facetPtr=NULL; 266 this->facetPtr=NULL; //maybe this->facetPtr = new facet(); 254 267 this->baseRing=currRing; 255 268 this->UCN=1; 269 this->numFacets=0; 256 270 } 257 271 … … 271 285 this->baseRing=currRing; 272 286 this->UCN=1; 287 this->numFacets=0; 273 288 } 274 289 … … 279 294 */ 280 295 //NOTE Prolly need to specify the facet to flip over 281 gcone(const gcone& gc )296 gcone(const gcone& gc, const facet &f) 282 297 { 283 298 this->next=NULL; 284 299 this->numVars=gc.numVars; 285 this->UCN=(gc.UCN)+1; //add 1 to the UCN of previous cone 300 this->UCN=(gc.UCN)+1; //add 1 to the UCN of previous cone. This is NOT UNIQUE! 286 301 facet *fAct= new facet(); 287 302 this->facetPtr=fAct; … … 305 320 } 306 321 307 /** \brief Default destructor */ 308 ~gcone(){;} //destructor 322 /** \brief Default destructor 323 */ 324 ~gcone() 325 { 326 //NOTE SAVE THE FACET STRUCTURE!!! 327 } 309 328 310 329 … … 340 359 //delete iv; 341 360 //delete f; 342 } 361 } 343 362 344 363 /** \brief Set gcone::numFacets */ … … 531 550 fAct->next = new facet(); 532 551 fAct=fAct->next; //this should definitely not be called in the above while-loop :D 552 this->numFacets++; 533 553 }//if (isFlippable==FALSE) 534 554 //delete load; … … 551 571 552 572 //Compute the number of facets 553 this->numFacets=ddineq->rowsize; 573 // wrong because ddineq->rowsize contains only irredundant facets. There can still be 574 // non-flippable ones! 575 //this->numFacets=ddineq->rowsize; 554 576 555 577 //Clean up but don't delete the return value! (Whatever it will turn out to be) … … 1417 1439 for (int ii=0; ii<this->numFacets; ii++) 1418 1440 { 1419 cout << "------------" << endl;1441 cout << endl << "------------" << endl; 1420 1442 ddakt = dd_CopyMatrix(ddineq); 1421 1443 set_addelem(ddakt->linset,ii+1); … … 1423 1445 dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err); 1424 1446 1425 dd_WriteMatrix(stdout,ddakt);1447 //dd_WriteMatrix(stdout,ddakt); 1426 1448 ddpolyh=dd_DDMatrix2Poly(ddakt, &err); 1427 1449 P=dd_CopyGenerators(ddpolyh); … … 1432 1454 * and add the resulting vector to the int matrix facet::codim2Facets 1433 1455 */ 1456 this->facetPtr->codim2Ptr = new facet(2); //construct a (codim-2)-facet 1457 facet *codim2Act; 1458 codim2Act = this->facetPtr->codim2Ptr; 1434 1459 for (int jj=1;jj<=P->rowsize;jj++) 1435 1460 { 1436 1461 intvec *n = new intvec(this->numVars); 1437 normalize(P,jj,*n); 1438 //fAct->addCodim2Facet(n); 1462 normalize(P,jj,*n); 1463 codim2Act->setFacetNormal(n); 1464 codim2Act->next = new facet(2); 1465 codim2Act = codim2Act->next; 1439 1466 n->show(); 1440 1467 delete n; 1441 } 1442 1443 //intvec *load = new intvec(this->numVars); 1468 } 1444 1469 1445 1470 dd_FreeMatrix(ddakt); 1446 1471 dd_FreePolyhedra(ddpolyh); 1447 } 1448 //gc.showFacets(); 1449 1472 } 1450 1473 } 1451 1474 … … 1463 1486 //NOTE: gcTmp may be deleted, gcRoot from main proc should probably not! 1464 1487 1465 }//void noRevS(gcone &gc) 1466 1467 void normalize(dd_MatrixPtr const &M, int line, intvec &n) 1488 }//void noRevS(gcone &gc) 1489 1490 1491 /** \brief Make a set of rational vectors into integers 1492 * 1493 * We compute the lcm of the denominators and multiply with this to get integer values 1494 * \param dd_MatrixPtr,intvec 1495 */ 1496 void normalize(dd_MatrixPtr const &M, int const line, intvec &n) 1468 1497 { 1469 1498 mpz_t denom[this->numVars]; … … 1476 1505 mpz_init(kgV); 1477 1506 mpz_init(tmp); 1478 //intvec *ivres = new intvec(this->numVars);1479 // intvec ivres(this->numVars);1480 1507 1481 1508 for (int ii=0;ii<(M->colsize)-1;ii++) … … 1484 1511 mpz_init(z); 1485 1512 mpq_get_den(z,M->matrix[line-1][ii+1]); 1486 //mpz_out_str(stdout,10,z);1487 1513 mpz_set( denom[ii], z); 1488 1514 mpz_clear(z); 1489 1515 } 1516 1490 1517 /*Compute lcm of the denominators*/ 1491 1518 mpz_set(tmp,denom[0]); … … 1494 1521 mpz_lcm(kgV,tmp,denom[ii]); 1495 1522 } 1523 1496 1524 /*Multiply the nominators by kgV*/ 1497 1525 mpq_t qkgV,res; 1498 1526 mpq_init(qkgV); 1499 // mpq_canonicalize(qkgV);1500 1527 mpq_set_str(qkgV,"1",10); 1501 // mpq_canonicalize(qkgV); 1528 mpq_canonicalize(qkgV); 1529 1502 1530 mpq_init(res); 1503 1531 mpq_set_str(res,"1",10); 1504 //mpq_canonicalize(res);1505 //mpq_set_z(qkgV,kgV);1532 mpq_canonicalize(res); 1533 1506 1534 mpq_set_num(qkgV,kgV); 1507 //mpq_set_den(qkgV,1);1535 1508 1536 // mpq_canonicalize(qkgV); 1509 1537 for (int ii=0;ii<(M->colsize)-1;ii++) 1510 1538 { 1511 1539 mpq_mul(res,qkgV,M->matrix[line-1][ii+1]); 1512 // (*ivres)[ii]=(int)mpz_get_d(mpq_numref(res));1513 1540 n[ii]=(int)mpz_get_d(mpq_numref(res)); 1514 1541 } 1515 1542 //mpz_clear(denom[this->numVars]); 1516 1543 mpz_clear(kgV); 1517 mpq_clear(qkgV); mpq_clear(res); 1518 1519 //return ivres; 1544 mpq_clear(qkgV); mpq_clear(res); 1545 1520 1546 } 1521 1547 … … 1541 1567 1542 1568 for (int jj=0; jj<M->rowsize; jj++) 1543 { 1569 { 1544 1570 comp = fAct->getFacetNormal(); 1545 1571 for (int ii=0; ii<this->numVars; ii++) … … 1547 1573 dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]); 1548 1574 } 1549 fAct = fAct->next; 1575 if(fAct->next!=NULL) 1576 { 1577 fAct = fAct->next; 1578 } 1550 1579 }//jj 1551 1580 … … 1690 1719 gcAct->numVars=pVariables; 1691 1720 gcAct->getGB(inputIdeal); 1692 gcAct->getConeNormals(gcAct->gcBasis); 1693 cout << "ding" << endl; 1721 gcAct->getConeNormals(gcAct->gcBasis); 1694 1722 gcAct->noRevS(*gcAct); 1695 1723 res=gcAct->gcBasis;
Note: See TracChangeset
for help on using the changeset viewer.