Changeset 472eeb in git for kernel/gfan.cc
- Timestamp:
- May 15, 2009, 3:54:46 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 294312ffcc6c4d753fa40971861665f124f63851
- Parents:
- 8f63e4c7ff0fb85b12623e48dd7beeb869ab2257
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r8f63e4c r472eeb 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-05-1 4 09:55:36 $5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.5 1 2009-05-14 09:55:36 monerjan Exp $6 $Id: gfan.cc,v 1.5 1 2009-05-14 09:55:36 monerjan Exp $4 $Date: 2009-05-15 13:54:46 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.52 2009-05-15 13:54:46 monerjan Exp $ 6 $Id: gfan.cc,v 1.52 2009-05-15 13:54:46 monerjan Exp $ 7 7 */ 8 8 … … 212 212 class gcone 213 213 { 214 private: 215 int numFacets; //#of facets of the cone 214 private: 216 215 ring rootRing; //good to know this -> generic walk 217 216 ideal inputIdeal; //the original … … 222 221 223 222 public: 224 /** Pointer to the first facet */223 /** \brief Pointer to the first facet */ 225 224 facet *facetPtr; //Will hold the adress of the first facet; set by gcone::getConeNormals 226 225 227 226 /** # of variables in the ring */ 228 227 int numVars; //#of variables in the ring 228 229 /** # of facets of the cone 230 * This value is set by gcone::getConeNormals 231 */ 232 int numFacets; //#of facets of the cone 229 233 230 234 /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/ … … 276 280 277 281 intvec *ivtmp = new intvec(this->numVars); 278 ivtmp = gc.facetPtr->getFacetNormal(); 279 //ivtmp->show(); 282 ivtmp = gc.facetPtr->getFacetNormal(); 280 283 281 284 ideal gb; 282 285 gb=gc.facetPtr->getFlipGB(); 283 this->gcBasis=gb;//gc.facetPtr->getFlipGB(); //this cone's GB is the flipped GB 284 //idShow(this->gcBasis); 286 this->gcBasis=gb; //this cone's GB is the flipped GB 285 287 286 288 /*Reverse direction of the facet normal to make it an inner normal*/ … … 394 396 aktpoly=(poly)I->m[i]; //get aktpoly as i-th component of I 395 397 pCompCount=pLength(aktpoly); //How many terms does aktpoly consist of? 398 #ifdef gfan_DEBUG 396 399 cout << "Poly No. " << i << " has " << pCompCount << " components" << endl; 400 #endif 397 401 398 402 int *v=(int *)omAlloc((numvar+1)*sizeof(int)); … … 469 473 for (int jj = 1; jj <ddcols; jj++) 470 474 { 471 #ifdef GMPRATIONAL472 475 double foo; 473 476 foo = mpq_get_d(ddineq->matrix[kk][jj]); … … 475 478 std::cout << "fAct is " << foo << " at " << fAct << std::endl; 476 479 #endif 477 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 478 #endif 479 480 //(*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 481 //check for flipability here 482 // if (jj<ddcols) //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :) 483 // { 484 //fAct->next = new facet(); //If so: instantiate new facet. Otherwise this->next=NULL due to the constructor 485 // } 480 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 486 481 }//for (int jj = 1; jj <ddcols; jj++) 482 487 483 /*Quick'n'dirty hack for flippability*/ 488 484 bool isFlippable=FALSE; … … 512 508 delete load; 513 509 }//for (int kk = 0; kk<ddrows; kk++) 510 514 511 /* 515 512 Now we should have a linked list containing the facet normals of those facets that are … … 526 523 delete iv; 527 524 } 525 526 //Compute the number of facets 527 this->numFacets=ddineq->rowsize; 528 528 529 529 //Clean up but don't delete the return value! (Whatever it will turn out to be) … … 1142 1142 } 1143 1143 1144 /** 1144 /** \brief Checks whether a given facet is a search facet 1145 1145 * Determines whether a given facet of a cone is the search facet of a neighbouring cone 1146 1146 * This is done in the following way: … … 1319 1319 void noRevS(gcone &gc, bool usingIntPoint=FALSE) 1320 1320 { 1321 facet *fListPtr = new facet(); 1321 facet *fListPtr = new facet(); //The list containing ALL facets we come across 1322 1322 facet *fAct = new facet(); 1323 1323 fAct = gc.facetPtr; … … 1356 1356 fAct=fAct->next; //iterate 1357 1357 } 1358 } 1358 } 1359 else/*Facets of facets*/ 1360 { 1361 dd_MatrixPtr ddineq,P,ddakt; 1362 dd_rowset impl_linset, redset; 1363 dd_ErrorType err; 1364 dd_rowindex newpos; 1365 1366 ddineq = facets2Matrix(gc); 1367 1368 /*Now set appropriate linearity*/ 1369 dd_PolyhedraPtr ddpolyh; 1370 for (int ii=0; ii<ddineq->rowsize; ii++) 1371 { 1372 cout << "------------" << endl; 1373 ddakt = dd_CopyMatrix(ddineq); 1374 set_addelem(ddakt->linset,ii+1); 1375 // dd_WriteMatrix(stdout,ddakt); 1376 1377 dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err); 1378 1379 // dd_WriteMatrix(stdout,ddakt); 1380 ddpolyh=dd_DDMatrix2Poly(ddakt, &err); 1381 P=dd_CopyGenerators(ddpolyh); 1382 dd_WriteMatrix(stdout,P); 1383 1384 intvec *load = new intvec(this->numVars); 1385 1386 dd_FreeMatrix(ddakt); 1387 dd_FreePolyhedra(ddpolyh); 1388 } 1389 1390 } 1359 1391 1360 1392 //NOTE Hm, comment in and get a crash for free... … … 1367 1399 fAct = fListPtr; 1368 1400 gcone *gcTmp = new gcone(gc); //copy 1369 gcTmp->flip(gcTmp->gcBasis,fAct);1401 //gcTmp->flip(gcTmp->gcBasis,fAct); 1370 1402 //NOTE: gcTmp may be deleted, gcRoot from main proc should probably not! 1371 1403 1372 1404 }//void noRevS(gcone &gc) 1405 1406 /** \brief Construct a ddMatrix from a cone's list of facets 1407 * 1408 */ 1409 dd_MatrixPtr facets2Matrix(gcone const &gc) 1410 { 1411 facet *fAct = new facet(); 1412 fAct = gc.facetPtr; 1413 dd_MatrixPtr M; 1414 dd_rowrange ddrows; 1415 dd_colrange ddcols; 1416 ddcols=(this->numVars)+1; 1417 ddrows=this->numFacets; 1418 M=dd_CreateMatrix(ddrows,ddcols); 1419 1420 //dd_set_global_constants(); 1421 1422 intvec *comp = new intvec(this->numVars); 1423 1424 for (int jj=0; jj<M->rowsize; jj++) 1425 { 1426 comp = fAct->getFacetNormal(); 1427 for (int ii=0; ii<this->numVars; ii++) 1428 { 1429 dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]); 1430 } 1431 fAct = fAct->next; 1432 }//jj 1433 delete comp; 1434 1435 return M; 1436 } 1373 1437 1374 1438 /** \brief Write information about a cone into a file on disk … … 1390 1454 } 1391 1455 else 1392 { 1456 { /*gcOutputFile << "UCN" << endl; 1457 gcOutputFile << this->UCN << endl;*/ 1393 1458 gcOutputFile << "RING" << endl; 1394 1459 //Write this->gcBasis into file … … 1402 1467 fAct = gc.facetPtr; 1403 1468 gcOutputFile << "FACETS" << endl; 1404 while(fAct ->next!=NULL)1469 while(fAct!=NULL) 1405 1470 { 1406 1471 intvec *iv = new intvec(gc.numVars);
Note: See TracChangeset
for help on using the changeset viewer.