Changeset 5435c3 in git
- Timestamp:
- May 12, 2009, 5:30:29 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- cb6cdaaa807284703d4425ec7714979ea30194ae
- Parents:
- 1fcefdd0abdf3767dc01bd67bbda1d17b3674379
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r1fcefd r5435c3 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-05-1 1 14:27:44$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1. 49 2009-05-11 14:27:44monerjan Exp $6 $Id: gfan.cc,v 1. 49 2009-05-11 14:27:44monerjan Exp $4 $Date: 2009-05-12 15:30:29 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.50 2009-05-12 15:30:29 monerjan Exp $ 6 $Id: gfan.cc,v 1.50 2009-05-12 15:30:29 monerjan Exp $ 7 7 */ 8 8 … … 21 21 #include "ring.h" 22 22 #include "prCopy.h" 23 #include <iostream> //deprecated23 #include <iostream> 24 24 #include <bitset> 25 25 #include <fstream> //read-write cones to files … … 67 67 intvec *fNormal; 68 68 69 /** \brief An interior point of the facet*/ 70 intvec *interiorPoint; 71 72 /** \brief Universal Cone Number 73 * The number of the cone the facet belongs to 74 */ 75 int UCN; 76 69 77 /** \brief The Groebner basis on the other side of a shared facet 70 78 * … … 129 137 { 130 138 idShow(this->flipGB); 139 } 140 141 void setUCN(int n) 142 { 143 this->UCN=n; 144 } 145 146 int getUCN() 147 { 148 return this->UCN; 149 } 150 151 void setInteriorPoint(intvec *iv) 152 { 153 this->interiorPoint = ivCopy(iv); 154 } 155 156 intvec *getInteriorPoint() 157 { 158 return this->interiorPoint; 131 159 } 132 160 … … 191 219 /* TODO in order to save memory use pointers to rootRing and inputIdeal instead */ 192 220 intvec *ivIntPt; //an interior point of the cone 221 int UCN; //unique number of the cone 193 222 194 223 public: … … 212 241 this->facetPtr=NULL; 213 242 this->baseRing=currRing; 243 this->UCN=1; 214 244 } 215 245 … … 228 258 this->inputIdeal=I; 229 259 this->baseRing=currRing; 260 this->UCN=1; 230 261 } 231 262 … … 238 269 { 239 270 this->next=NULL; 240 this->numVars=gc.numVars; 271 this->numVars=gc.numVars; 272 this->UCN=(gc.UCN)+1; //add 1 to the UCN of previous cone 241 273 facet *fAct= new facet(); 242 274 this->facetPtr=fAct; … … 244 276 intvec *ivtmp = new intvec(this->numVars); 245 277 ivtmp = gc.facetPtr->getFacetNormal(); 246 ivtmp->show();278 //ivtmp->show(); 247 279 248 280 ideal gb; … … 280 312 { 281 313 ivIntPt->show(); 314 } 315 316 /** \brief Set gcone::numFacets */ 317 void setNumFacets() 318 { 319 } 320 321 /** \brief Get gcone::numFacets */ 322 int getNumFacets() 323 { 324 return this->numFacets; 325 } 326 327 int getUCN() 328 { 329 return this->UCN; 282 330 } 283 331 … … 431 479 //(*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 432 480 //check for flipability here 433 if (jj<ddcols) //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :)434 {481 // if (jj<ddcols) //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :) 482 // { 435 483 //fAct->next = new facet(); //If so: instantiate new facet. Otherwise this->next=NULL due to the constructor 436 }484 // } 437 485 }//for (int jj = 1; jj <ddcols; jj++) 438 486 /*Quick'n'dirty hack for flippability*/ … … 473 521 { 474 522 intvec *iv = new intvec(this->numVars); 475 interiorPoint(ddineq, *iv); 523 interiorPoint(ddineq, *iv); //NOTE ddineq contains non-flippable facets 476 524 this->setIntPoint(iv); //stores the interior point in gcone::ivIntPt 477 525 delete iv; … … 945 993 946 994 /** \brief Compute an interior point of a given cone 995 * Result will be written into intvec iv 947 996 */ 948 997 void interiorPoint(dd_MatrixPtr const &M, intvec &iv) //no const &M here since we want to remove redundant rows … … 957 1006 //M->representation=dd_Inequality; 958 1007 //M->objective-dd_LPMin; //Not sure whether this is needed 959 dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1); 960 //cout << "TICK 1" << endl; 961 1008 1009 //NOTE: Make this n-dimensional! 1010 //dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1); 1011 962 1012 //dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err); 963 1013 //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;} … … 975 1025 if (err!=dd_NoError){cout << "Error during dd_MakeLPForInteriorFinding in gcone::interiorPoint" << endl;} 976 1026 #ifdef gfan_DEBUG 977 // dd_WriteLP(stdout,lpInt);1027 // dd_WriteLP(stdout,lpInt); 978 1028 #endif 979 1029 … … 1263 1313 }//while(fAct->next!=NULL) 1264 1314 }//reverseSearch 1315 1316 /** \brief The new method of Markwig and Jensen 1317 */ 1318 void noRevS(gcone &gc) 1319 { 1320 facet *fListPtr = new facet(); 1321 facet *fAct = new facet(); 1322 fAct = gc.facetPtr; 1323 1324 dd_set_global_constants(); 1325 dd_rowrange ddrows; 1326 dd_colrange ddcols; 1327 ddrows=2; //Each facet is described by its normal 1328 ddcols=gc.numVars+1; // plus one for the standard simplex 1329 1330 while(fAct->next!=NULL) 1331 { 1332 /*Compute an interior point for each facet*/ 1333 dd_MatrixPtr ddineq; 1334 ddineq=dd_CreateMatrix(ddrows,ddcols); 1335 intvec *comp = new intvec(this->numVars); 1336 comp=fAct->getFacetNormal(); 1337 for(int ii=0; ii<this->numVars; ii++) 1338 { 1339 dd_set_si(ddineq->matrix[0][ii+1],(*comp)[ii]); 1340 dd_set_si(ddineq->matrix[1][ii+1],1); //Assure we search in the pos. orthant 1341 } 1342 set_addelem(ddineq->linset,1); //We want equality in the first row 1343 //dd_WriteMatrix(stdout,ddineq); 1344 interiorPoint(ddineq,*comp); 1345 /**/ 1346 #ifdef gfan_DEBUG 1347 cout << "IP is"; 1348 comp->show(); cout << endl; 1349 #endif 1350 //Store the interior point and the UCN 1351 fListPtr->setInteriorPoint( comp ); 1352 fListPtr->setUCN( gc.getUCN() ); 1353 1354 dd_FreeMatrix(ddineq); 1355 fAct=fAct->next; //iterate 1356 } 1357 1358 //NOTE Hm, comment in and get a crash for free... 1359 //dd_free_global_constants(); 1360 gc.writeConeToFile(gc); 1361 1362 /*2nd step 1363 Choose a facet from fListPtr, flip it and forget the previous cone 1364 */ 1365 fAct = fListPtr; 1366 gcone *gcTmp = new gcone(gc); //copy 1367 gcTmp->flip(gcTmp->gcBasis,fAct); 1368 //NOTE: gcTmp may be deleted, gcRoot from main proc should probably not! 1369 1370 }//void noRevS(gcone &gc) 1265 1371 1266 1372 /** \brief Write information about a cone into a file on disk … … 1313 1419 1314 1420 gcOutputFile.close(); 1421 delete fAct; fAct=NULL; 1315 1422 } 1316 1423 }//writeConeToFile(gcone const &gc) … … 1336 1443 searchMethod method; 1337 1444 method = noRevS; 1338 //method = reverseSearch;1445 // method = reverseSearch; 1339 1446 1340 1447 #ifdef gfan_DEBUG … … 1394 1501 gcAct->numVars=pVariables; 1395 1502 gcAct->getGB(inputIdeal); 1396 gcAct->getConeNormals(gcAct->gcBasis); 1397 gcAct->writeConeToFile(*gcAct); 1503 gcAct->getConeNormals(gcAct->gcBasis); 1504 cout << "ding" << endl; 1505 gcAct->noRevS(*gcAct); 1398 1506 res=gcAct->gcBasis; 1399 1507 }
Note: See TracChangeset
for help on using the changeset viewer.